Since functional components do not have an instance associated with them, you cannot use them directly with render or renderIntoDocument. Trying to wrap a functional component is a good idea, unfortunately, using a div does not work for the same reason. DOM components also do not return a component instance; instead, they return the base DOM node.
This is all that can be said that you cannot use the test utility or your own components as the "root" component that you are running. Instead, you'll want to wrap your functional components in a shell component that uses createClass or extends React.Component .
class Wrapper extends React.Component { render() { return this.props.children } } let component = renderIntoDocument(<Wrapper><Greeter /></wrapper>
Gotcha, as this may be reason enough to use a third-party test library, such as a popular enzyme, or my own: teaspoon . Both abstract on issues such as wrapping and deploying functional components seamlessly for you, so you donโt have to worry about what type of component you are trying to make.
source share