-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update unsafe_componentWillReceiveProps react-json-tree #644
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
Update unsafe_componentWillReceiveProps react-json-tree #644
Conversation
…' of github.com:BrunoFenzl/redux-devtools into update-UNSAFE_componentWillReceiveProps-react-json-tree
merging upstream back in
|
@BrunoFenzl Thanks for making a PR!
|
|
@Methuselah96 Thanks for your feedback!
|
|
@BrunoFenzl Yeah, I'm fine with adding |
|
Hi, can this PR be merged? Thanks. |
|
The feedback I gave still needs to be addressed. Feel free to create your own PR since it seems like this PR might be abandoned. |
|
@Methuselah96 Would you be open to a PR which removes these unsafe calls by converting the JSONTree and JSONNestedNode to function components and using hooks? |
|
@defunctzombie Yeah, go for it! |
|
Resolved by #1288. |
This PR attempts to solve #635.
unsafe_componentWillReceivePropsis currently used in two components:JSONTreeandJSONNestedNode.In
JSONTreeI extracted the propertiesthemeandinvertThemefromPropsto a separate interface and extended theStateandPropsinterfaces with it. The reason being, that the new static methodgetDerivedStateFromPropsdoes not have access to the current props, so properties that need to be compared should be mirrored in the local state object.In
JSONNestedNodethere is no need to check for derived state at all. The propertyexpandedcan be copied to state and re-rendering is checked anyway in theshouldComponentUpdatelifecycle hook.I'm looking forward to feedback and will be glad to refactor if needed.