📜  useRoutes - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:19.108000             🧑  作者: Mango

代码示例1
// React Router v6:
// hook functionally equivalent to , but uses JS objects instead
// of , use this hook instead of 'react-router-config' (React Router v5)
import { useRoutes } from 'react-router-dom';

function App() {
  let element = useRoutes([
    {
      path: '/',
      element: ,
      children: [
        { path: 'messages', element:  },
        { path: 'tasks', element:  }
      ]
    },
    { path: 'team', element:  }
  ]);

  return element;
}