The State of Components

A component that uses state has two snippets of code as given here

A<h1>It is {this.state.date.toLocaleTimeString()}.</h1>

B.<MyStuff thing={this.state.thing}/>

Which of the snippets may lead to issues in the architecture?

Options
  1. Both A and B are fine. The children receive the state as props
  2. Yes, this is fine for A but not for B since user defined components would have their own state
  3. Yes, this is fine for B, but not for A, since the state can be modified in the child with unpredictable consequences
  4. No, this is not fine for either A or B since the state may be cascaded and would lead to unpredictable re-rendering

Related Posts