React-router urls don't work when refreshing or writing manually

前端 未结 30 2645
时光取名叫无心
时光取名叫无心 2020-11-21 05:07

I\'m using React-router and it works fine while I\'m clicking on link buttons, but when I refresh my webpage it does not load what I want.

For instance, I am in

30条回答
  •  广开言路
    2020-11-21 05:31

    Using HashRouter worked for me with Redux also, just simply replace:

    import {
      Router //replace Router
    } from "react-router-dom";
    
    ReactDOM.render(
        
        
             //replace here saying Router
                
            
        
    , document.getElementById("app"));
    registerServiceWorker();
    

    to:

    import {
      HashRouter //replaced with HashRouter
    } from "react-router-dom";
    
    ReactDOM.render(
        
        
             //replaced with HashRouter
                
            
        
    , document.getElementById("app"));
    registerServiceWorker();
    

提交回复
热议问题