Move next route out of state

This commit is contained in:
Chi Vinh Le
2018-05-01 16:18:17 +02:00
parent 9310a4734d
commit e8cd938b65
@@ -20,7 +20,7 @@ import OrganizationSettings from './OrganizationSettings';
import { withRouter } from 'react-router';
class ConfigureContainer extends React.Component {
state = { nextRoute: '' };
nextRoute = '';
savePending = async () => {
await this.props.updateSettings(this.props.pending);
@@ -40,10 +40,9 @@ class ConfigureContainer extends React.Component {
};
gotoNextRoute = () => {
const { nextRoute } = this.state;
if (nextRoute) {
this.props.router.push(nextRoute);
this.setState({ nextRoute: '' });
if (this.nextRoute) {
this.props.router.push(this.nextRoute);
this.nextRoute = '';
}
};
@@ -51,7 +50,7 @@ class ConfigureContainer extends React.Component {
const nextRoute = `/admin/configure/${section}`;
if (this.shouldShowSaveDialog()) {
await this.setState({ nextRoute });
this.nextRoute = nextRoute;
this.props.showSaveDialog();
} else {
// Just go to the section
@@ -65,7 +64,7 @@ class ConfigureContainer extends React.Component {
routeLeave = ({ pathname }) => {
if (this.shouldShowSaveDialog()) {
this.setState({ nextRoute: pathname });
this.nextRoute = pathname;
this.props.showSaveDialog();
return false;
}