Updating state on props change in React Form

前端 未结 11 1958
时光说笑
时光说笑 2020-12-02 04:15

I am having trouble with a React form and managing the state properly. I have a time input field in a form (in a modal). The initial value is set as a state variable in

11条回答
  •  执笔经年
    2020-12-02 05:02

    It's quite clearly from their docs:

    If you used componentWillReceiveProps for re-computing some data only when a prop changes, use a memoization helper instead.
    

    Use: https://reactjs.org/blog/2018/06/07/you-probably-dont-need-derived-state.html#what-about-memoization

提交回复
热议问题