-
-
Notifications
You must be signed in to change notification settings - Fork 85
Console warning when adding reactn to class #134
Comments
This is just a deprecation warning, and ReactN should function fine despite it. That said, I would like to get this log out of your developer environment where possible. Code trail: The intention of this method is to remove subscriptions that will no longer exist on the next render cycle. For example, if I am subscribed to changes in property I do not believe there is an alternative to using The best course of action may be to do (pseudo code):
I am unsure if |
Hi, |
If removing the subscriptions occurred post-render, then there would be no subscriptions to state change. I am not sure if |
You are right 😁, what about other methods that fire before render? |
Hey take a look at this |
For now, is it not worth using the codemod the react guys wrote to patch these methods? they'll still be there in React 17, and the warnings are pretty annoying, especially on React Native. Can codemod with:
|
Older version of react that are still supported by reactn may not have the UNSAFE_* method... Will try this weekend to fork it and thinker with lifecycle method and give some feedback
|
Hi @CharlesStover, I have attempted the pseudocode you mentioned and it works! |
Thank you for accepting the PR 👍 , I made another one by using shouldComponentUpdate instead of UNSAFE_componentWillUpdate if using newer react to avoid deprecated methods. |
Thank you all very much for your contributions. :) |
I'm sorry I know this is closed, but I'm not sure I understand the solution? I have the latest version of react-native (0.61.5) and the latest version of reactn (2.2.5), and I have absolutely nowhere in my code that I'm using deprecated methods like componentWillUpdate (and I tried npx react-codemod rename-unsafe-lifecycles). My logs keep getting inundated with this warning to the point that it's difficult to debug other problems. Was there a consensus on how to suppress this? |
@jasonbodily hi, seems that the current release on npm does not include yet this fix. You may temporarily clone from this master or temporarily use version “SIAPCN/reactnUnsafe” in your package.json instead of 2.2.5, it contains the workaround that suppressed the warnings |
Thank you! |
@umbertoghio Unless Travis botched deployment, NPM should match the master branch at this time at v2.2.5. |
Indeed, I confirm the last changes are in 2.2.5 |
Are you aware of why your fix in 2.2.5 wouldn't address Jason's issue? |
Hi, I just verified my work project (was still using forked) and with 2.2.5 all componentWillUpdate warnings that used to get on older versions are gone 😄 (both on React Web and React Native). @jasonbodily Are you sure the warnings are coming from your reactn components and not from third party components? As in my work project is using an older Expo I setup a new react-native setup, tried 2.2.5 and I got no warnings (See screenshots)....so I can't really explain why my fix are still causing the warnings. Edit: In the screenshot I was in debug, imported reactn instead of React, Compo is a regular class component. I got a warning to validate setup when adding componentWillUpdate method. |
Those pesky logs are gone! Clearing and rebuilding did it, so thank you! And many thanks for going out of your way to address my concerns! |
Hi, I recently upgraded my react-native to 0.61.5 and reactn to 2.2.6 in a project of mine and I seem to be getting the same |
Hi @TuckerMassad . This issue was fixed to the best of our ability in 2.2.5. If you can try If 2.2.5 gives you the same warnings, could you follow the directions in this comment to see if that resolves your issues as it did for Jason. |
Hello,
I notice some warnings when adding reactn to a class:
`componentWillUpdate has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.
npx react-codemod rename-unsafe-lifecycles
in your project source folder.Please update the following components: ##ComponentName##`
How to reproduce:
Create a new project with create-react-app
Create a component
`import React, { Component } from 'react'
export default class Compo extends Component {
render() {
return (
I am a Component
)
}
}
`
and include it in App.js
Run -> No warnings
change first line to
`import React, { Component } from 'reactn'
get warning:
`react-dom.development.js:12449 Warning: componentWillUpdate has been renamed, and is not recommended for use. See https://fb.me/react-unsafe-component-lifecycles for details.
npx react-codemod rename-unsafe-lifecycles
in your project source folder.Please update the following components: Compo`
The text was updated successfully, but these errors were encountered: