componentWillMount is deprecated and will be removed in the next major version 0.54.0 in React Native

前端 未结 3 1200
挽巷
挽巷 2020-11-29 05:12

I use the react native latest version of 0.54.0 and Whenever run the apps on iOS there is found warning about deprecate the lifecycle methods. and also please update the com

3条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 05:45

    componentDidMount isn't deprecated and is definitely still safe to use, so there's no need to add UNSAFE_ to that method. The componentWillSomething methods are the ones that seem to be on their way out. Instead of componentWillMount, use a constructor for the stuff that doesn't produce side-effects, and use componentDidMount for the stuff that does.

提交回复
热议问题