Accessing Redux Store from routes set up via React Router

前端 未结 4 1213
暖寄归人
暖寄归人 2021-01-30 07:20

I would like to make use of react-router\'s onEnter handler in order to prompt users to authenticate when entering a restricted route.

So far my route

4条回答
  •  粉色の甜心
    2021-01-30 07:29

    Lots have changed over the time. onEnter no longer exists on react-router-4

    The following is from my real project for your reference

    export const getRoutes = (store) => {
      const PrivateRoute = ({ component: Component, ...rest }) => (
         (
          checkIfAuthed(store) ? (
            
          ) : (
            
          )
        )}/>
      )
    
      return (
        
          
    ) }

提交回复
热议问题