renderIntoDocument在测试后清理

Tom*_*ech 5 javascript reactjs

我正在查看React Test Utilities文档,特别是在renderIntoDocument函数中:

将组件渲染到文档中的分离DOM节点.

我想知道一旦我完成测试,我是否应该对我已呈现的组件做任何事情?

这有效:

const component = ReactTestUtils.renderIntoDocument(createElement(MyThing));

// do tests

unmountComponentAtNode(findDOMNode(component).parentElement);
Run Code Online (Sandbox Code Playgroud)

但我想知道这一步是否有必要,因为文档中没有提到.我目前的方法是否实际上有用,或者我可以使用renderIntoDocument而不用担心整理?