mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-10 10:02:02 +05:30
#337: fix setState after unmounted warning on AuthFlowRouteContents
This commit is contained in:
parent
9e3926f8e5
commit
1538bcb264
@ -18,14 +18,21 @@ export default class AuthFlowRouteContents extends Component {
|
||||
component: null
|
||||
};
|
||||
|
||||
_isMounted = false;
|
||||
|
||||
componentDidMount() {
|
||||
this.handleProps(this.props);
|
||||
this._isMounted = true;
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps: ComponentProps) {
|
||||
this.handleProps(nextProps);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this._isMounted = false;
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.state.component;
|
||||
}
|
||||
@ -41,6 +48,10 @@ export default class AuthFlowRouteContents extends Component {
|
||||
}
|
||||
|
||||
onRedirect(path: string) {
|
||||
if (!this._isMounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
component: <Redirect to={path} />
|
||||
});
|
||||
@ -49,6 +60,10 @@ export default class AuthFlowRouteContents extends Component {
|
||||
onRouteAllowed(props: ComponentProps) {
|
||||
const {component: Component} = props;
|
||||
|
||||
if (!this._isMounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({
|
||||
component: <Component {...props.routerProps} />
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user