fix StrictMode warnings by moving cWM to constructor#8
fix StrictMode warnings by moving cWM to constructor#8kylehalleman wants to merge 1 commit intodavidtheclark:masterfrom
Conversation
|
This is awesome @kylehalleman, thanks for contributing it! My only concern is with server-side rendering. While I know that this component probably isn't made for SSR, it'd be nice if it could at least render without throwing an exception. During SSR, I think that lifecycle methods like Do you think there's any way to make this not throw an exception on the server-side? |
|
Two approaches I could see addressing this. A simple one would be to check for Thoughts? |
|
Good ideas! Because |
With React 16.3
componentWillMountwas deprecated and aStrictModecomponent was introduced to help identify potential issues for the future async rendering in React.To make this project compatible with
StrictMode, I moved the code incomponentWillMountto theconstructor. Looking at the code incomponentWillMountit was safe to move it toconstructorsince it is merely setting an instance variable and not worrying about props changes.If this PR is approved and merged, I plan to make a similar PR to
react-aria-modalto update it to supportStrictMode.