-
Notifications
You must be signed in to change notification settings - Fork 369
new react getDerivedStateFromProps #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Would be good to get this to |
|
@STRML cool I've updated the PR to use |
this package uses flowtype (not typescript), that's why we use .js extension instead of .ts |
|
ah I see, thanks for the comment @daynin |
| }); | ||
| } | ||
| if (!state.resizing && | ||
| (props.width !== props.width || props.height !== props.height)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't work
props.width !== props.width // false (always, except cases with NaN)you should use componentDidMount here
| height: nextProps.height | ||
| }); | ||
| static getDerivedStateFromProps(props: ResizableProps, state:Object) { | ||
| if (props.width !== props.width || props.height !== props.height) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same case as above
|
The |
| }); | ||
| } | ||
| if (!state.resizing && | ||
| (props.width !== props.width || props.height !== props.height)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comparison doesn't make sense. You don't have access to the previous props. See react-grid-layout/react-draggable@fea778c
| }; | ||
|
|
||
| componentWillReceiveProps(nextProps: Object) { | ||
| static getDerivedStateFromProps(props: Object, state:Object) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use Props & State types
|
Closing in favor of #112 |
* refactor(Resizable): remove draggable state This must have been a vestigal bit of state from before the Resizable/ResizableBox refactor years ago. It is not actually needed and with the React 16.9 refactor to remove CWRP, it became obvious it was actually not useful. Fixes #99 Supersedes #100 Partially fixes #107, #110 * fix(ResizableBox): Fix 16.9 CWRP deprecation
Just a simple quick fix to get rid of the react 17.x messages. If you guys think this is not the best way to resolve it and would rather go the componentDidUpdate route feel free to delete this PR.