Skip to content

Instantly share code, notes, and snippets.

@agrcrobles
Created December 2, 2016 18:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agrcrobles/ba6832a3ecf8c8c47c0c4101aa0a2ffe to your computer and use it in GitHub Desktop.
Save agrcrobles/ba6832a3ecf8c8c47c0c4101aa0a2ffe to your computer and use it in GitHub Desktop.
import React from "react";
import { withRouter } from "react-router";
class Test extends React.Component {
constructor(props) {
super(props);
this.state = {
};
}
componentWillReceiveProps(nextProps) {
if (nextProps.AnyCondition) {
this.props.router.push("/anyPage");
}
//set state with next props or invoke event
this.setState({
});
}
render() {
return (
<div />
);
}
}
export default withRouter(Test);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment