All:
I am pretty new to React, I am wondering if anyone could give me a comparison between createClass and extends Component
The first question is why we need React.Component since we already have createClass?
Second, something specific is:
1. What does this.state looks like in extends Component mode: I try to use this.state in constructor(), but failed as undifined, does that mean I have to build this.state myself by giving it the whole state tree?
And one question for both modes:
If I want to use setState() with a complex object(which has nested data structure) how can I only update according part, for example, say the state is like:
State = {
title: "",
attrs: {
size: {
width:"100px",
height: "100px"
}
}
}
How can I only update the height using setState()? Should I use it like
setState({
attrs: {
size: {
height:"200px"
}
}
})
Thanks