当我尝试将路由器传递给组件时,我收到了这样的错误:
class Login extends React.Component {
onClick(){
Actions.login(this.context.router);
}
static contextTypes = {
router: React.PropTypes.func.isRequired
}
render(){
return (
<Card style={{
'maxWidth': '800px',
'margin': '30px auto',
'padding': '50px'
}}>
<CardText style={{
'textAlign': 'center'
}}>
To start chatting away, please log in with your Google account.
</CardText>
<RaisedButton style={{
display: 'block',
}} onClick={this.onClick.bind(this)}
label="Log in with Google" primary={true} />
</Card>
);
}
}
export default Login;
Run Code Online (Sandbox Code Playgroud)
然后我尝试将其传递给操作login,以便在记录后重定向到另一条路径.行动登录:
login(router){
return (dispatch) => {
let firebaseRef = new Firebase('https://front-react-stack.firebaseio.com');
firebaseRef.authWithOAuthPopup("google", (error, …Run Code Online (Sandbox Code Playgroud)