import { push } from 'react-router-redux'
export function requireAuth(Component) {
class AuthenticatedComponent extends React.Component {
componentWillMount() {
this.checkAuth(this.props.isAuthenticated);
}
componentWillReceiveProps(nextProps) {
this.checkAuth(nextProps.isAuthenticated);
}
checkAuth(isAuthenticated) {
if (!isAuthenticated) {
let redirectAfterLogin = this.props.location.pathname;
this.props.dispatch(push({pathname: "/login", search:`?redirect=${redirectAfterLogin}`}))
}
}
//....
}
Every time it moves to the login page. I realize that it call @LOCATION_CHANGE 2 time, in the second time it removes search value. It works fine if I handle it from button event
App.js
AuthenticatedComponent.js
Every time it moves to the login page. I realize that it call @LOCATION_CHANGE 2 time, in the second time it removes search value. It works fine if I handle it from button event
https://imgur.com/gzb1oZR