When I am trying to declare a state variable based on other state it is not working whatever I try. Is it forbidden by react itself or am I doing something wrong?
Basically I am trying to achieve something like:
class App extends Component {
state={
a:123,
b:234,
c:this.state.a+this.state.b
}
render() {
return (
<div className="App">
{this.state.c}
</div>
);
}
}
FYI: I am not trying to do something like calculating c in curly brackets like:
{this.state.a+this.state.b}
but rather interested in how it works inside the state.
Thanks for help!