ComponentWillMount warning

前端 未结 5 936
伪装坚强ぢ
伪装坚强ぢ 2021-01-12 18:20

I am creating a layout with inside. I am getting to this scene from another. So at the beginning another layout is rendered. After i go to the second scene (with TextInput

相关标签:
5条回答
  • 2021-01-12 18:47

    It is because componentWillMount will get deprecated soon in the next major version.Even if you are not using it getting this warning is to prevent you from using as it is the part of lifecycle we commonly use.

    0 讨论(0)
  • 2021-01-12 18:51

    ComponentWillMount is deprecated in react from version 16. You should move all the code from the componentWillMount to the constructor or componentDidMount.

    Please refer to below link for more explanation. https://reactjs.org/docs/react-component.html#componentwillmount

    0 讨论(0)
  • 2021-01-12 18:52

    componentWillMount could be easily fixed with a constructor initialization or possibly with componentDidMount

    it work for me :)

    0 讨论(0)
  • 2021-01-12 18:56

    Yes, because the componentWillMount and componentWillReceiveProps getting deprecated soon in React. I suggest you to use componentDidMount instead of componentWillMount.

    But you will still get those yellow box warnings because react-native is still using those for the internal components like Image, TouchableOpacity and a lot of other components. We need to wait for a new update to get rid of those warnings. Don't worry, Happy coding.

    0 讨论(0)
  • 2021-01-12 19:01

    I think, the ref of componentWillMount is in Component class implementation. not in the extend.

    0 讨论(0)
提交回复
热议问题