Sugan Zhang
Sugan Zhang

Reputation: 283

componentWillMount is deprecated and will be removed

I do not use componentWillMount method,but I still get the warning.It is trouble me. Help me,guys! React-native 0.55 Warning: componentWillMount is deprecated and will be removed in the next major version. Use componentDidMount instead. As a temporary workaround, you can rename to UNSAFE_componentWillMount.

Upvotes: 0

Views: 942

Answers (1)

Praz Solver
Praz Solver

Reputation: 543

Yup..

In future versions of React componentWillMount will be called more than once, so you should use componentDidMount for network requests.

Instead use "UNSAFE_componentWillMount()",

Note

This lifecycle was previously named componentWillMount. That name will continue to work until version 17.

Use to automatically update your components.

rename-unsafe-lifecycles codemod 

Upvotes: 1

Related Questions