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

时间:2017-03-24 07:34:01

标签: javascript reactjs react-router history

Web Tips Picture旁边的

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

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

图片旁边是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;

1 个答案:

答案 0 :(得分:14)

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

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