I am trying to navigate programmatically using RR4. After I save some data, I then want to render a Redirect
like this:
handleSave = () => {
this.props.mutate({
...
});
this.setState({
org: null
});
<Redirect to="/orgs" />
// return <Redirect to="/orgs" /> // Tried this also
};
I don't get an error, but the Redirect
does not get rendered. If I add a switch statement in my render
function, then it will work:
render() {
return ( this.state.rerender ? <Redirect to="/orgs" push /> :
<View>
...
</View>
)
}
This works like I want it to, but I don't like the ternary statement. Is there a way that I can add the Redirect
to the save function, like I tried in my first example?