render function
dynamic
render()
Renders a React component or builder into a detached node and returns the component instance.
By default the rendered instance will be unmounted after the current test, to prevent this behavior set
autoTearDown
to false. If autoTearDown
is set to true once it will, if provided, call autoTearDownCallback
once the component has been unmounted.
Implementation
/* [1] */ render(dynamic component,
{bool autoTearDown = true,
Element? container,
Callback? autoTearDownCallback}) {
var renderedInstance;
component = component is component_base.UiProps ? component() : component;
setComponentZone();
if (container == null) {
renderedInstance = react_test_utils.renderIntoDocument(component);
} else {
renderedInstance = react_dom.render(component, container);
}
if (autoTearDown) {
addTearDown(() {
unmount(renderedInstance);
if (autoTearDownCallback != null) autoTearDownCallback();
});
}
return renderedInstance;
}