I'm using the ReactRouter and want to do something like set state when the RouteNotFound component is hit (last one means no others above matched).
my this.handler
does a setState so that I can tell that it was called. That of course gives me an error saying "Cannot update during an existing state transition such as in a render".
Is there a way I can set my state to tell me which (I really want to know the last one) of the switch statements go executed?
render() {
return (
<div>
<Switch>
<Route exact path="/" component={Home}/>
<Route exact path="/p1" component={p1}/>
<Route exact path="/p2" component={p2}/>
<RouteNotFound action={this.handler} ></RouteNotFound>
</Switch>
</div>
);
}