What's the right way to pass form element state to sibling/parent elements?

后端 未结 10 756
情话喂你
情话喂你 2020-11-29 15:04
  • Suppose I have a React class P, which renders two child classes, C1 and C2.
  • C1 contains an input field. I\'ll refer to this input field as Foo.
  • M
10条回答
  •  Happy的楠姐
    2020-11-29 15:14

    The first solution, with keeping the state in parent component, is the correct one. However, for more complex problems, you should think about some state management library, redux is the most popular one used with react.

提交回复
热议问题