【发布时间】:2018-04-02 14:03:30
【问题描述】:
如何以正确的方式根据条件调度操作: 我执行以下操作,但出现语法错误。
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 }
}}/>
)
)
)}/>
}
【问题讨论】:
标签: reactjs firebase redux react-redux react-router-v4