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

Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code.

Open S-Nakib opened this issue 4 years ago • 8 comments

I am currently using react 16.13.1 and google-maps-react 2.0.6. I am getting this warning on using Map and GoogleApiWrapper. "Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://fb.me/react-unsafe-component-lifecycles 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

Please update the following components: Wrapper"

S-Nakib avatar Sep 16 '20 17:09 S-Nakib

I know it is not good idea but it works. just remove <React.StrictMode> from index.js

mukhtorov avatar Oct 13 '20 16:10 mukhtorov

Why not update it to componentDidUpdate or either of the other two options provided in the React documentation? After React 16 this function will no longer work.

https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops

zoness32 avatar Oct 29 '20 04:10 zoness32

anyone knows if there is already an active PR for this issue?

redefinered avatar Nov 10 '20 23:11 redefinered

Same for me is it posible to fix this bug to make this package alive ?

vincenthure avatar Mar 21 '21 11:03 vincenthure

Would be great to have this fixed.

rbruggem avatar Apr 07 '21 10:04 rbruggem

anyone knows if there is already an active PR for this issue?

anyone?

Berdugo1994 avatar Sep 18 '21 18:09 Berdugo1994

hear is the fixer , Step 1: go to node_modules > google-maps-react > GoogleApiComponent.js > { change line no. 149 & 150 UNSAFE_componentWillReceiveProps --> componentDidUpdate }

Step 2: then install npm i patch-package Step 3: add this line in pkg.json "scripts": { + "postinstall": "patch-package" } Step 4: then install npx patch-package package-name There you go just simple restart application and you are done

CodeWithMufaddal avatar Mar 23 '23 07:03 CodeWithMufaddal

hear is the fixer , Step 1: go to node_modules > google-maps-react > GoogleApiComponent.js > { change line no. 149 & 150 UNSAFE_componentWillReceiveProps --> componentDidUpdate } Step 2: then install npm i patch-package Step 3: add this line in pkg.json "scripts": { + "postinstall": "patch-package" } Step 4: then install npx patch-package package-name There you go just simple restart application and you are done

Sir ,npx patch-package package-name (What is that "package-name") bro , tks

in this case google-maps-react so the last step would something like this Step 4: npx patch-package google-maps-react

Context: patch-package is a npm library use to make any changes in node_modules libraries , some times pkgs like this (google-maps-react) cause some error and we really really need them to use in our react application so we just fix them rather sending pull on git

CodeWithMufaddal avatar Nov 08 '23 06:11 CodeWithMufaddal