-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Warn for update on different component in render #17099
Conversation
ReactDOM: size: 0.0%, gzip: -0.0% Details of bundled changes.Comparing: a8c6a1b...bd8fbdb react-art
react-dom
react-test-renderer
react-reconciler
react-native-renderer
|
6b0ffdf
to
bd8fbdb
Compare
'Cannot update during an existing state transition (such as ' + | ||
'within `render`). Render methods should be a pure function of ' + | ||
'props and state.', | ||
); |
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 use warningWithoutStack
instead of warning
here?
@@ -491,6 +491,50 @@ describe('ReactHooksWithNoopRenderer', () => { | |||
]); | |||
expect(ReactNoop.getChildren()).toEqual([span(22)]); | |||
}); | |||
|
|||
it('warns about render phase update on a different component', async () => { |
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.
I presume there's already a test for it not warning if it's the same component?
@sebmarkbage @gaearon Do we want to land this warning? If so I'll update it |
@ermanzohre Can I ask you to please not “approve” old pull requests? Your actions are creating notification noise for everyone watching the repo. Thanks. |
This warning already exists for class components, but not for functions. It does not apply to render phase updates to the same component, which have special semantics that we do support.
bd8fbdb
to
1051db9
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Details of bundled changes.Comparing: 085d021...1051db9 react-dom
react-art
react-test-renderer
react-native-renderer
react-reconciler
Size changes (experimental) |
Details of bundled changes.Comparing: 085d021...1051db9 react-dom
react-native-renderer
react-reconciler
react-art
react-test-renderer
Size changes (stable) |
switch (fiber.tag) { | ||
case FunctionComponent: | ||
case ForwardRef: | ||
case SimpleMemoComponent: { |
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.
I guess this should include Block too?
This warning already exists for class components, but not for functions.
It does not apply to render phase updates to the same component, which have special semantics that we do support.