render method
Examines props and state and returns a ReactNode.
This method is required for class components.
The function should be pure, meaning that it should not modify component state, it returns the same result each time it is invoked, and it does not directly interact with browser / DOM apis.
If you need to interact with the browser / DOM apis, perform your work in componentDidMount
or the other lifecycle methods instead. Keeping render
pure makes components easier to think about.
Implementation
@override
render() {
if (state.hasError) { // [2]
return (Dom.div()
..key = 'ohnoes'
..addTestId('ErrorBoundary.unrecoverableErrorInnerHtmlContainerNode')
)();
}
return (RecoverableErrorBoundary()
..addTestId('RecoverableErrorBoundary')
..modifyProps(addUnconsumedProps)
)(props.children); // [1]
}