https://facebook.github.io/react/blog/2017/07/26/error-handling-in-react-16.html
Dear recomposers lets think about this feature and may be an enhancer we could provide.
I just had a play around too after seeing their <ErrorBoundry> wrapper and came up with something like this, similar to the spinnerWhileLoading example from docs
Edit: not proposing as part of the lib, just one way to do it yourself :)
const showErrorMessage = ErrorComponent =>
compose(
lifecycle({
componentDidCatch(error, errorInfo) {
this.setState({ error, errorInfo })
},
}),
branch(props => props.error, renderComponent(ErrorComponent)),
)
/////
import showErrorMessage from '../utils'
const WillThrow = props =>
<div>
{props.undefined[0]}
</div>
const ErrorMessage = () => <h1>Something went wrong.</h1>
const App = props =>
<div>
App
<WillThrow />
</div>
export default compose(
showErrorMessage(ErrorMessage)
)(App)
Most helpful comment
I just had a play around too after seeing their
<ErrorBoundry>wrapper and came up with something like this, similar to thespinnerWhileLoadingexample from docsEdit: not proposing as part of the lib, just one way to do it yourself :)