React-native-render-html: componentWillMount, componentWillReceiveProps are depricated

Created on 24 Oct 2019  路  11Comments  路  Source: meliorence/react-native-render-html

These 2 methods should be removed from the code.

WARN Warning: componentWillMount has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

  • Move code with side effects to componentDidMount, and set initial state in the constructor.
  • Rename componentWillMount to UNSAFE_componentWillMount to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: HTML

WARN Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

  • Move data fetching code or side effects to componentDidUpdate.
  • If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
  • Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run npx react-codemod rename-unsafe-lifecycles in your project source folder.

Please update the following components: HTML

Most helpful comment

Fix available in version 4.2.0.

All 11 comments

same issue here

I am using react-native0.60.5 and getting warning-
"componentWillReceiveProps is deprecated and will be removed in the next major version".

Can I get confirmation to resolve this issue in the next release, so that I could continue using this library without any problem in the next version of react-native also?

same issue here

.... and same.

and same issue here

same

@ThomasHenrissat Please update

Same here. The issue is in MyProjectName/node_modules/react-native-render-html/src/HTMLImage.js at line 43 and MyProjectName/node_modules/react-native-render-html/src/HTML.js at lines 80 and 88. I added UNSAFE_ to the names on these lines as the warning from React told me. This stops the warning from popping up and seems to work but I'm not sure if this will keep on working if I have to update my project again later. I think React is going to get rid of this option in the future. According to React: "These methods are considered legacy and you should avoid them in new code" (https://reactjs.org/docs/react-component.html).

same

Fix available in version 4.2.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabriel-tentaculo picture gabriel-tentaculo  路  7Comments

xipgroc picture xipgroc  路  6Comments

HarrisKoffi picture HarrisKoffi  路  5Comments

kanikas24 picture kanikas24  路  5Comments

KimJeonghun91 picture KimJeonghun91  路  4Comments