React Router Switch Component Matches

后端 未结 2 1683
[愿得一人]
[愿得一人] 2021-01-13 20:59

In the react router docs here it says:

Consider this code:




        
2条回答
  •  不思量自难忘°
    2021-01-13 21:14

    As they're not contained within a ... element, they're all evaluated, and evaluated independently.

    The router has no knowledge of the users in the system - it's only looking for a string match within the path.

    Something like:

    if (path === '/about') { return 'About' }
    if (typeof path === 'String') { return 'User' }
    if (true) { return 'noMatch' }
    

提交回复
热议问题