HashRouter tips error in react router 4.x
Asked Answered
A

1

9

Next to the Web Tips Picture

https://i.sstatic.net/A2OGn.png

Warning: Hash history cannot PUSH the same path; a new entry will not be added to the history stack

Tips error , This is when I click on the link again


Next to Picture is React-Router File Code...

https://i.sstatic.net/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;
Antilles answered 24/3, 2017 at 7:34 Comment(0)
S
16

If you use the component Link for navigation, you may want to set the prop replace on it.

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

Sold answered 25/3, 2017 at 19:49 Comment(2)
Thank you very muchAntilles
Be careful. This'll cause your browser can not navigate previous route when you clicked the back button.Darbydarce

© 2022 - 2024 — McMap. All rights reserved.