React router nested routing inner layer route cannot be found

topic description

react-router nesting routing elements, the relevant contents of the child elements cannot be loaded, and the whole address cannot match

sources of topics and their own ideas

want to use outer route to implement template page, login, 404 and other pages.
use sub-route to dynamically load content in the inner layer of template page

related codes

/ / Please paste the code text below (do not replace the code with pictures)
/ / outer routing App.js

render() {
    return (
        <Switch>
            <Route exact component={Home} path="/" />
            <Route component={Login} path="/login" />
            <Route component={NotFound} />
        </Switch>
    )
  }

/ / Inner Home.js

render() {
        return (
            <Layout>
                <Header>Some Info.</Header>
                <Content>
                    <Switch>
                        <Route exact path="/" component={MyLayout} />
                        <Route path="/temperature/month" component={TemperatureMonth} />
                        <Route path="/temperature/day" component={TemperatureDay} />
                    </Switch>
                </Content>
            </Layout>
        );
    }

what result do you expect? What is the error message actually seen?

enter http://127.0.0.1:3000/temperature/month, and the result matches to the outer NotFound.

Apr.09,2021

  1. because the Switch tag is used to wrap the route, only one route will be rendered, and the route / temperature/month does not match in App.js, so the < Route component= {NotFound} / > is rendered.
  2. Why doesn't it match < Route exact component= {Home} path= "/" / > this? Because it is a precise match, / temperature/month cannot match this component.

how to solve this problem?
1. Adjust the Route order, remove the exact match, and let the / temperature/month match to the Home component

          <Route component={Login} path="/login" />
          <Route component={Home} path="/" />
          <Route component={NotFound} />
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf64a8-32007.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf64a8-32007.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?