I'm having an issue with exception handling with react-router@3.0.0
My router is attached like this:
try {
ReactDOM.render(<Router history={appHistory}>
<Route path='/' component={Wrapper}>
<Route path='bad' component={BadComponent}/>
</Route>
</Router>, domElement);
} catch(ex) {
ReactDOM.render(<Exception ex={ex}/>, domElement);
}
My issue is that if Wrapper
throws a render exception we end up in the catch block. Great!
If Wrapper
works fine, but BadComponent
throws a render exception we do not. Boo!
If we reach this point, then the router completely stops working and we can't navigate to any known good routes.
The react-router API doesn't mention error handling, so I'm a little stuck.
Is there a way of getting the exception back to the top layer so it can fail gracefully?