How to nest routes in React Router v4?

后端 未结 6 1226
予麋鹿
予麋鹿 2020-12-01 05:39

Is there a way to nest routes in React Router v4?

This works:

  
    
6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 06:25

    You're AppBar component is in charge of rendering Customers. For customers to be called, you have to render the children of AppBar. Anything directly nested under AppBar is a child of AppBar.

    import React from 'react';
    
    const AppBar = ({ children }) => (
      

    stuff

    {children}
    ); export default AppBar

    Please note that only AppBar will render when you visit "/". AppBar and Customers will render when you visit "/customers".

提交回复
热议问题