Reactjs 我想在firebase身份验证后将用户重定向到上一页
我正在尝试在通过Google Firebase验证后将用户重定向到上一页。我正在使用“react router dom”管理react中的视图。当我点击我的登录按钮时,它会将我重定向到谷歌登录并让我登录,但它不会像我预期的那样将我发送回上一页。有人知道为什么会发生这种情况,或者我如何重定向到上一页吗Reactjs 我想在firebase身份验证后将用户重定向到上一页,reactjs,firebase,firebase-authentication,react-router-dom,Reactjs,Firebase,Firebase Authentication,React Router Dom,我正在尝试在通过Google Firebase验证后将用户重定向到上一页。我正在使用“react router dom”管理react中的视图。当我点击我的登录按钮时,它会将我重定向到谷歌登录并让我登录,但它不会像我预期的那样将我发送回上一页。有人知道为什么会发生这种情况,或者我如何重定向到上一页吗 Import React from 'react'; import { withRouter } from 'react-router-dom'; import { auth, provider }
Import React from 'react';
import { withRouter } from 'react-router-dom';
import { auth, provider } from '../firebase';
const SignIn = props => {
const handleGoogleSignIn = () => {
auth.signInWithRedirect(provider).then(() => {
props.history.goBack();
})
}
return(
<button onClick={handleGoogleSignIn}>
Sign in with Google
</button>
)
}
export default withRouter(SignIn);
从“React”导入React;
从“react router dom”导入{withRouter};
从“../firebase”导入{auth,provider};
常量符号=道具=>{
const handleGoogleSignIn=()=>{
auth.signInWithRedirect(提供程序)。然后(()=>{
props.history.goBack();
})
}
返回(
使用谷歌登录
)
}
使用路由器导出默认值(登录);
我使用的路线是:
import React from 'react';
import { Switch, Route } from 'react-router-dom';\
import Landing from './Components/Landing';
import SignIn from './Components/SignIn';
export default (
<Switch>
<Route exact path='/' component={Landing} />
<Route path='/sign-in' component={SignIn} />
</Switch>
);
从“React”导入React;
从“react router dom”导入{Switch,Route}\
从“./组件/平台”导入平台;
从“./Components/SignIn”导入登录;
导出默认值(
);
听起来你好像还没有在Google Firebase API登录时设置重定向URL?