Serve another(standalone) page or static file in website built with react

前端 未结 6 1614
陌清茗
陌清茗 2021-02-02 09:53

I have a website built with react, which uses react-router. For some route I want to serve another page or static file, but since all request are forwarded to react router, its

6条回答
  •  走了就别回头了
    2021-02-02 10:01

    Use Switch combined with a NoMatch component, combined with webdeb's solution:

    
      
    window.location.reload()} />

    This will match routes, show 404 if no valid href exists, and show a file or something if it's a valid href.

提交回复
热议问题