makotot/react-scrollspy

Supress console warning messages for componentWillMount and componentWillReceiveProps

stoutlabs opened this issue ยท 9 comments

I'm getting console warnings for both componentWillMount and componentDidMount after upgrading my React version to 16.9.0.

This can be easily fixed by changing those to UNSAFE_componentWillMount and UNSAFE_componentWillReceiveProps in scrollspy.js.

Should I make a PR? Or is someone already working on an update?

Update: After tinkering around on my own, that won't quite fix the problem. It then throws this warning intermittently:
Warning: Can't perform a React state update on an unmounted component. ...

I'll take another look ASAP to see if I can figure out a proper fix, unless someone is already working on this.

Seeing warnings as well, let me know if you find a fix

same here. Will this package be updated?

I'm also getting warnings for componentWillReceiveProps. Hopefully, there's a fix soon.

@stoutlabs Can you push the code you have up to a branch so I can work on it? I suspect that warning isn't related to your change. From reading this library's code, the issue is most likely caused by throttle, which delays calling setState by 100ms, which means if the function is called, then the component is unmounted, the warning will be emitted. The solution is to clear the throttle timeout when the component is unmounted, but this should be unrelated to changing componentWillReceiveProps.

I'd love to see this fixed. @stoutlabs @ZhangYiJiang lmk if there's something I can do to help.

I'm getting a message too

Warning: componentWillReceiveProps has been renamed, and is not recommended for use
Please update the following components: Scrollspy

Looks like this repo may no longer be maintained. Hopefully this is not the case and maybe we will see some past pull requests accepted soon. Untill then I guess we can fork this repo for a quick fix and rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps. I tried doing it on my windows machine but looks like I may have to do it in WSL since the NPM install process builds the project using yarn with osx/linux/bash style commands that my terminal emulator for Windows cant handle. I will try and make the time to setup my dev env in WSL and try again but in the meatime maybe someone with a *nix OS could give it a whirl.

In the meantime here is a PR for the quickfix:
#121

Also experiencing this. Would be great to have a fix for it.

I have just merged #121 (Thank you, @apolopena!) and released as v3.4.1.
Feel free to reopen this issue if the warning still is displayed.