-
-
Save Mozartted/0210b4d80335a5b922165c33e6d12b92 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { connect } from "react-redux"; | |
import { withRouter } from "react-router"; | |
class AppCheck extends React.Component { | |
componentDidUpdate(prevProps) { | |
const { dispatch, redirectUrl } = this.props; | |
const isLoggingOut = prevProps.isLoggedIn && !this.props.isLoggedIn; | |
const isLoggingIn = !prevProps.isLoggedIn && this.props.isLoggedIn; | |
if (isLoggingIn) { | |
// dispatch(navigateTo(redirectUrl)) | |
} else if (isLoggingOut) { | |
// do any kind of cleanup or post-logout redirection here | |
} | |
} | |
render() { | |
return this.props.children; | |
} | |
} | |
const mapStateToProps = state => { | |
console.log(state); | |
return { | |
isLoggedIn: state.isAuthenticated, | |
redirectUrl: state.redirectUrl | |
}; | |
}; | |
export default withRouter(connect(mapStateToProps)(AppCheck)); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment