-
Notifications
You must be signed in to change notification settings - Fork 47.9k
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
Inject overrideProps() fn to DevTools #14427
Inject overrideProps() fn to DevTools #14427
Conversation
This function will enable editing props for function components, host nodes, and special types like memo and forwardRef.
if (fiber.alternate) { | ||
fiber.alternate.pendingProps = fiber.pendingProps; | ||
} | ||
flushPassiveEffects(); |
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.
Why is this after setting the pendingProps? What if these effects synchronously renderers an update to this tree?
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.
Somewhat arbitrary (so I'll move it).
Seems a little weird either way, since such a synchronous re-renderer would mean we're reading from stale memoizedProps
when we do our copy.
ReactDOM: size: 0.0%, gzip: 0.0% Details of bundled changes.Comparing: a22880e...3c84766 react-dom
react-art
react-native-renderer
react-test-renderer
react-reconciler
Generated by 🚫 dangerJS |
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.
In the future we might add a resetPropsOverride(fiber, path) to unshadow it. E.g. in the case where we have a more persistent override mechanism.
* Inject overrideProps() fn to DevTools This function will enable editing props for function components, host nodes, and special types like memo and forwardRef.
* Inject overrideProps() fn to DevTools This function will enable editing props for function components, host nodes, and special types like memo and forwardRef.
This function will enable editing props for function components, host nodes, and special types like
memo
andforwardRef
.Copying the update logic into React will also enable us to add more complex behavior in the future– such as the ability to override props in a way that won't get overridden unless the component is re-rendered with a new props value.
Demo
Here's a demo that shows me editing a

Context.Provider
value,React.memo
andReact.forwardRef
props, host node props, and function component props.Unblocks facebook/react-devtools/pull/1249