Do you want to request a feature or report a bug?
No
What is the current behavior?
setState's behaviour
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/reactjs/69z2wepo/).
Not a bug, But it is raising issue among developers and may create bugs.
What is the expected behavior?
Explanation
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Latest version.
Simple example.
We are setting initial state in the constructor.
setState({
questions: {
"1": {display: "none"}
}
})
Later we are updating like this:
var questions = this.state.questions
questions["1"].display = "block"
this.setState({ questions: questions })
Why is this approach bad? Or not bad? Can anybody explain with examples? What approach we take can lead to ugly codes.
Do you want to request a feature or report a bug?
No
What is the current behavior?
setState's behaviour
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template: https://jsfiddle.net/reactjs/69z2wepo/).
Not a bug, But it is raising issue among developers and may create bugs.
What is the expected behavior?
Explanation
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Latest version.
Simple example.
We are setting initial state in the constructor.
setState({
questions: {
"1": {display: "none"}
}
})
Later we are updating like this:
var questions = this.state.questions
questions["1"].display = "block"
this.setState({ questions: questions })
Why is this approach bad? Or not bad? Can anybody explain with examples? What approach we take can lead to ugly codes.