0
我在使用react-router时遇到了问题。我想建立一个带有firebase的登录系统并作出反应。React路由器2.6.0如何重定向点击功能
当用户点击“登录”按钮,用户名和密码通过认证后,页面将重定向到主页。
我的路线是这样的:
ReactDOM.render(
<Router history={hashHistory}>
<Route path='/'>
<IndexRoute component={Index}></IndexRoute>
<Route path='/start' component={Layout}></Route>
</Route>
</Router>,
app);
Index
组件是登录页面。
这里是我的点击功能:
Jump(){
var password = this.refs.password.value;
var email = this.refs.username.value;
console.log(email, password);
firebase.auth().signInWithEmailAndPassword(email, password)
.catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
})
.then(function(res){
if(res !== undefined){
browserHistory.push('/#/start');
//want to do the redirect here.
}
})
}
我试图browserHistory.push()
,但它不工作。任何人都知道如何重定向到函数内部?真的很感谢!