Passing props to component in React Router 4

后端 未结 6 1754
太阳男子
太阳男子 2021-02-05 06:39

I am new to react-router and I just started writing an app using react-router V4. I would like to to pass props to components rendered by and I am w

6条回答
  •  既然无缘
    2021-02-05 07:32

    I'm fairly new to react-router and came across a similar issue. I've created a wrapper based on the Documentation and that seems to work.

    // Wrap Component Routes
    function RouteWrapper(props) {
      const {component: Component, ...opts } = props
    
      return (
        (
         
       )}/>
     )
    }
    
     
    

    So far so good

提交回复
热议问题