react router v4 default page(not found page)

前端 未结 4 1145
生来不讨喜
生来不讨喜 2020-11-27 13:28

This is common purpose, directing unmatch request to notfound page.

making this with react-router v4 looks like previous versions and I expect this sample works bel

4条回答
  •  爱一瞬间的悲伤
    2020-11-27 14:10

    React Router's No Match documentation covers this. You need to import the component, then you can remove the path attribute altogether.

    A renders the first child that matches. A with no path always matches

    This is the example that uses:

    
      

    So in your case, you'd simply drop the path="*" and introduce the :

    
      
      
      
    
    

    Remember to include Switch to your import statement at the top.

提交回复
热议问题