google-maps-react icon indicating copy to clipboard operation
google-maps-react copied to clipboard

Warning: componentWillReceiveProps has been renamed, and is not recommended for use.

Open Restoration opened this issue 5 years ago • 7 comments

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: Wrapper

Hi guys. It above error is shown when I using ReactHooks and googleApiWrapper. How do I fix this error?? Can I set API key and loading component without using googleApiWrapper?? Do you have another way??

Restoration avatar Sep 20 '19 07:09 Restoration

Experiencing the same issue as well

loq24 avatar Dec 16 '19 05:12 loq24

I had to go into the source code in the node_modules folder like this:

node_modules / google-maps-react / dist / GoogleApiComponent.js

Lines 147 and 148 were changed from: key: 'componentWillReceiveProps', value: function componentWillReceiveProps(props) { to key: 'UNSAFE_componentWillReceiveProps', value: function UNSAFE_componentWillReceiveProps(props) {

This got rid of that warning for me. This isn't a permanent solution because the developers of React are saying it will be removed eventually.

A permanent solution would be the developers of this repo taking the advice of the warning and shifting to a safer lifecycle method.

Earle-Poole avatar Jan 20 '20 15:01 Earle-Poole

I had to go into the source code in the node_modules folder like this:

node_modules / google-maps-react / dist / GoogleApiComponent.js

Lines 147 and 148 were changed from: key: 'componentWillReceiveProps', value: function componentWillReceiveProps(props) { to key: 'UNSAFE_componentWillReceiveProps', value: function UNSAFE_componentWillReceiveProps(props) {

This got rid of that warning for me. This isn't a permanent solution because the developers of React are saying it will be removed eventually.

A permanent solution would be the developers of this repo taking the advice of the warning and shifting to a safer lifecycle method.

Instead of adding "UNSAFE_" to both values replace them for componentDidUpdate

rinaexplore avatar Feb 21 '20 00:02 rinaexplore

It's not a great practice to edit code inside the node_modules folder. It looks like this project hasn't been worked on for awhile, is there any chance that these lifecycle methods will be updated? It would be a pain to switch to something new, but the lifecycle methods that are throwing those warnings will stop being supported soon.

erinwilder avatar Mar 19 '20 20:03 erinwilder

I ended up forking the repo and making the changes myself. There were several other reasons why I forked, such as adding right click props to markers.

On Thu, Mar 19, 2020, 3:31 PM Erin [email protected] wrote:

It's not a great practice to edit code inside the node_modules folder. It looks like this project hasn't been worked on for awhile, is there any chance that these lifecycle methods will be updated? It would be a pain to switch to something new, but the lifecycle methods that are throwing those warnings will stop being supported soon.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fullstackreact/google-maps-react/issues/376#issuecomment-601402231, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKSZ5OWD4Z3KHOBDUKORMSDRIJ6LFANCNFSM4IYT6WAQ .

Earle-Poole avatar Mar 19 '20 21:03 Earle-Poole

Same issue, there is no solution ?

RomainLt avatar May 26 '20 08:05 RomainLt

I am also facing the same issue

SubhasisDebsharma avatar Aug 17 '20 15:08 SubhasisDebsharma