Let us suppose we have a parent component:
class ParentComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
titleState: undefined
};
}
componentWillMount() {
// import Title string from JSON in order to assign it to titleState
this.setState({ titleState: jsonResponse["title"] });
}
render() {
return (
<div>
<ChildComponent title={this.state.titleState} />
</div>
);
}
}
class ChildComponent extends React.Component {
render() {
return (
<div>
<h>Title is: {this.props.title}</h>
</div>
);
}
}
Let us suppose server response with title comes with a significant delay so that in the beginning what we see on the screen is:
Title is:
But when response comes with jsonResponse["title"] value: "Bone Collector" we see:
Title is: Bone Collector
Now the question is:
Is it guaranteed that the state change in Parent Component will cause the Child Component to be rerendered so that is is updated with new ParentComponent's state via props?