Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion scripts/fiber/tests-failing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponent-test.js

src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
* should still throw when rendering to undefined
* throws when rendering null at the top level

src/renderers/shared/shared/__tests__/ReactMultiChildText-test.js
* should reorder keyed text nodes
Expand Down
1 change: 1 addition & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1403,6 +1403,7 @@ src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
* should distinguish between a script placeholder and an actual script tag
* should have findDOMNode return null when multiple layers of composite components render to the same null placeholder
* works when switching components
* can render null at the top level
* does not break when updating during mount
* preserves the dom node during updates

Expand Down
18 changes: 12 additions & 6 deletions src/renderers/shared/shared/__tests__/ReactEmptyComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The 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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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', () => {
Expand Down