报错/Warning: You should not use <Route component> and <Route children> in the same route; <Route component> will be ignored

This error will appear in the following cases

The first

<Switch>
       <Route exact path="/home/index" component={HomeIndex} />
       <Route path="/home/order" component={HomeOrder}>
          <Route path="/home/order2" component={HomeOrder2}></Route>
       </Route>
       <Route path="/home/assets" component={Assets} />
    </Switch>    

The following components can not be nested Route Route components , react-router4 version of the above would not allow such a write

The second (Super Pit !!!)

<Switch>
       <Route exact path="/home/index" component={HomeIndex} />
       <Route path="/home/order" component={HomeOrder}>
       </Route>
       <Route path="/home/assets" component={Assets} />
    </Switch> 

You can not have a space between Route components wrap ! Therefore, either <Route> </ Route> or written in such a way and a self-closing tags <Route /> !!!

Guess you like

Origin www.cnblogs.com/liang-meng/p/11899815.html