1
如何根據條件以正確的方式發送操作: 我做了以下操作,但出現語法錯誤。如何根據路由器中的條件發送操作
const PrivateRoute = ({ component: Component, ...rest }) => {
<Route {...rest} render={props => (
firebase.auth().onAuthStateChanged((user) => user
?(
store.dispatch(actions.login(user.uid));
<Component {...props}/>
)
:(
store.dispatch(actions.logout());
<Redirect to={{
pathname: '/login',
state: { from: props.location }
}}/>
)
)
)}/>
}