Let's suppose I have the following code in my ReactJS application. In my constructor where i define the state part. How do I resolve the result
in the state object.
constructor () {
super();
this.state = {
a: 1,
b: 2,
result: this.state.a + this.state.b
};
}
There is a similar question self reference in object literal declaration but it is for vanilla JavaScript. How do i achieve the same in React.