New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid using deprecated/UNSAFE_* React methods #519
Comments
👋 Thanks for opening your first issue. A contributor should give feedback soon. If you haven’t already, please check out the contributing guidelines. You can also join #polaris on the Shopify Partners Slack. |
Following an update to eslint-plugin-react in jsx-eslint/eslint-plugin-react#2069 componentWillMount, componentWillReceiveProps and componentWillUpdate will not trigger a react/no-deprecated warning as they are considered legacy componenets but they're not officially deprecated just yet. We should still move away from them. |
Enabling react/no-unsafe with |
React has deprecated its use of a selection of lifecycle methods it has deemed to be unsafe.
The
componentWillMount
,componentWillReceiveProps
andcomponentWillUpdate
lifecycle methods have the potential to cause headaches and We should use the newer, more stable lifecycle methods ofgetDerivedStateFromProps
andgetSnapshotBeforeUpdate
instead.We could shuffle onto using
UNSAFE_componentWillMount
etc but that doesn't fix the root problem.The good news is ESLint now warns about our usage of these methods so we no longer have to think about this when doing PR reviews, however there are still a few places in existing code where they are used. Any existing use of these functions should be removed
Search the codebase for
react/no-deprecated
and refactor the usage of thecomponentWillMount
,componentWillReceiveProps
andcomponentWillUpdate
to use the new lifecycle functions.As of 2018-10-04, searching the codebase for
react/no-deprecated
shows the following Components are affected:The text was updated successfully, but these errors were encountered: