Nested routes with react router v4 / v5

后端 未结 11 1990
广开言路
广开言路 2020-11-22 12:34

I am currently struggling with nesting routes using react router v4.

The closest example was the route config in the React-Router v4 Documentation.

I want t

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-22 13:21

    A complete answer for React Router v5.

    
    const Router = () => {
      return (
        
          
          
          
           (
              
                
                  
                  
                  
                  
                
              
            )}
          />
          
          
        
      );
    };
    
    export default Router;
    
    const Dashboard = ({ children }) => {
      return (
        
          
          {children}
        
      );
    };
    
    export default Dashboard;
    

    Github repo is here. https://github.com/webmasterdevlin/react-router-5-demo

提交回复
热议问题