-
Notifications
You must be signed in to change notification settings - Fork 49.8k
Open
Labels
Component: Test RendererReact Core TeamOpened by a member of the React Core TeamOpened by a member of the React Core TeamType: Feature Request
Description
Do you want to request a feature or report a bug?
Report a bug
What is the current behavior?
This test
import React from 'react';
import { createPortal } from 'react-dom';
import renderer from 'react-test-renderer';
const Drop = () => (
createPortal(
<div>hello</div>,
this.dropContainer
)
);
test('Drop renders', () => {
const component = renderer.create(
<div>
<input />
<Drop />
</div>
);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});fails with
Invariant Violation: Drop(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.
This test passes if I wrap createPortal in a container.
<div>
{createPortal(
<div>hello</div>,
this.dropContainer
)}
</div>What is the expected behavior?
The code without the parent container works fine in the browser. So it seems that I'm adding the parent div just for the test to pass. I believe react-test-renderer should support empty returns?
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
Lastest
HaNdTriX, kairiruutel, mrchief, falconx, kossel and 37 moresilverwind, juliankigwana and andoks
Metadata
Metadata
Assignees
Labels
Component: Test RendererReact Core TeamOpened by a member of the React Core TeamOpened by a member of the React Core TeamType: Feature Request