react-router dynamic segments crash when accessed

后端 未结 2 729
慢半拍i
慢半拍i 2020-12-13 08:52

I have a route configuration that looks like this (showing only the parts that I think may be relevant):

var React = require(\'react\');

var Router = require         


        
2条回答
  •  北海茫月
    2020-12-13 09:42

    Thanks for your analysis, it helped me to realize it wasn't an issue with React Router but my own paths.

    I added into the of my index.html and it worked (:

    Edit for React Router 3:

    Since early 2016, React Router will show a warning when you set :

    Warning: Automatically setting basename using  is deprecated 
    and will be removed in the next major release. The semantics of     
    are subtly different from basename. Please pass the basename explicitly in the
    options to createHistory
    

    It's better to do something like this instead:

    const history = useRouterHistory(createHistory)({
        basename: '/'
    });
    

提交回复
热议问题