React renderToString error boundary fallback
npm install async-react-ssr-error-boundarycomponentDidCatch lifecycle method, but it is not working when you render page on server using renderToString.
react-ssr-error-boundary.
react-ssr-error-boundary to your package.json:
npm install react-ssr-error-boundary
`
or
`
yarn add react-ssr-error-boundary
`
Usage:
Code below will render on server if ProblemComponent rendering fails:
`javascript
import ErrorFallBack from 'react-ssr-error-boundary'
function App() {
return Error Fallback}>
}
`
If yours ProblemComponent depends on context (your are using Redux for example), you should create your own ErrorFallBack component by providing contextTypes:
`javascript
import { withContext } from 'react-ssr-error-boundary'
const ErrorFallBack = withContext({ store: PropTypes.object })
function App() {
return Error Fallback}>
}
``