HashRouter在反应路由器4.x中提示错误

Mr *_*. Y 8 javascript history reactjs react-router

Web Tips图片旁边

https://i.stack.imgur.com/A2OGn.png

Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack
Run Code Online (Sandbox Code Playgroud)

提示错误,这是我再次点击链接的时候


图片旁边是React-Router文件代码......

https://i.stack.imgur.com/WgqqN.png

import { HashRouter, Route } from 'react-router-dom';

import { Provider } from  'react-redux';
import View from './containers';
import configureStore from './store/configureStore';

const store = configureStore();

const AppRouter = () => (
    <Provider store={store}>
        <HashRouter>
            <View.App.Container>
                <Route path='/' exact={true} component={View.App.Dashboard} />
                <Route path='/Todo' component={View.Todo.Container} />
                <Route path='/News' render={() => (
                    <View.News.Container>
                        <Route path='/News/List' render={() => (
                            <h2>News List Show</h2>
                            )} />
                    </View.News.Container>
                )} />
            </View.App.Container>
        </HashRouter>
    </Provider>
);

export default AppRouter;
Run Code Online (Sandbox Code Playgroud)

luf*_*ffy 14

如果使用组件链接进行导航,则可能需要replace在其上设置道具.

https://reacttraining.com/react-router/web/api/Link/replace-bool

  • 小心.这会导致您单击后退按钮时浏览器无法导航上一个路线. (6认同)