Nested routes with react router v4 / v5

后端 未结 11 1992
广开言路
广开言路 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:07

    Some thing like this.

    import React from 'react';
    import {
      BrowserRouter as Router, Route, NavLink, Switch, Link
    } from 'react-router-dom';
    
    import '../assets/styles/App.css';
    
    const Home = () =>
      
        

    HOME

    ; const About = () =>

    About

    ; const Help = () =>

    Help

    ; const AdminHome = () =>

    root

    ; const AdminAbout = () =>

    Admin about

    ; const AdminHelp = () =>

    Admin Help

    ; const AdminNavLinks = (props) => (

    Admin Menu

    Admin Home Admin Help Admin About Home {props.children}
    ); const NormalNavLinks = (props) => (

    Normal Menu

    Home Help About Admin {props.children}
    ); const App = () => (
    ); export default App;

提交回复
热议问题