-
Notifications
You must be signed in to change notification settings - Fork 51k
[Fiber] Relax test about rendering top-level null #8640
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,14 +246,20 @@ describe('ReactEmptyComponent', () => { | |
| expect(assertions).toBe(3); | ||
| }); | ||
|
|
||
| it('throws when rendering null at the top level', () => { | ||
| // TODO: This should actually work since `null` is a valid ReactNode | ||
| it('can render null at the top level', () => { | ||
| var div = document.createElement('div'); | ||
| expect(function() { | ||
|
|
||
| if (ReactDOMFeatureFlags.useFiber) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @acdlite is going to add a flag for the old behavior which should throw this same error.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was going to start working on that—but happy to have @acdlite fix it. I didn't do it initially because I thought we're going to introduce a flag to disable all Fiber features including frags, and do it in a single pass. |
||
| ReactDOM.render(null, div); | ||
| }).toThrowError( | ||
| 'ReactDOM.render(): Invalid component element.' | ||
| ); | ||
| expect(div.innerHTML).toBe(''); | ||
| } else { | ||
| // Stack does not implement this. | ||
| expect(function() { | ||
| ReactDOM.render(null, div); | ||
| }).toThrowError( | ||
| 'ReactDOM.render(): Invalid component element.' | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| it('does not break when updating during mount', () => { | ||
|
|
||
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.
Is @spicyj ok with this divergence? Seems like it would be pretty easy to start relying on this, even accidentally.