Warning: [history] pushState is deprecated; use push instead

when using web package + reaction + react router + es6

Warning: [history] pushState is deprecated; use push instead

<pre> import React from 'react'; import ReactDOM from 'react-dom'; import {createHistory} from 'history'; import App from './component/app'; import About from './component/about'; import Concat from './component/concat'; import List from './component/list'; import {Router, Route} from 'react-router'; const history = createHistory(); const router = ( <Router history={history}> <Route path="/" component={App}> <Route path="about" component={About} /> <Route path="concat" component={Concat} /> <Route path="list/:id" component={List} /> <Route path="*" component={About}/> </Route> </Router> ); ReactDOM.render( router, document.getElementById('root') ); </pre> 
+5
source share
2 answers

Today I had the same problem due to a new merge request to the history repository:

https://github.com/rackt/history/commit/a9db75ac71b645dbd512407d7876799b70cab11c

[TEMP FIX] Update your package package.json, change "history" to "1.13.1" in the dependencies. Then upgrade "npm install" to upgrade.

[REAL FIX] Wait for someone to merge the patch into a response router.

+9
source

Previous versions of History (npm installation history) used pushState. pushState is an HTML5 feature regarding updating a URL without going to a page / template / component.

This was deprecated in honor of push ("path"), which is cleaner than the best syntax according to some.

Replace

 this.history.pushState(null, "/route/") 

with

 this.history.push('/store/' + storeId); 
+2
source

Source: https://habr.com/ru/post/1237544/


All Articles