简体   繁体   中英

Failed to execute 'pushState' on 'History' while injecting React app into Chrome extension

I'm trying to inject React app into the Chrome extension. I have also connected it with Redux. Unfortunately, when I start the extension, I get the following exception:

react-dom.production.min.js:17 Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'http://localhost:8000/' cannot be created in a document with origin 'chrome-extension://hajcaldemcjpnjmcjnocmiokajbbbfji' and URL 'chrome-extension://hajcaldemcjpnjmcjnocmiokajbbbfji/pop.html'.
    at http://localhost:8000/static/js/2.d6390d93.chunk.js:2:24695
    at Object.confirmTransitionTo (http://localhost:8000/static/js/2.d6390d93.chunk.js:2:22303)
    at push (http://localhost:8000/static/js/2.d6390d93.chunk.js:2:24606)
    at navigate (http://localhost:8000/static/js/2.d6390d93.chunk.js:2:48531)
    at onClick (http://localhost:8000/static/js/2.d6390d93.chunk.js:2:48088)
    at Object.m (http://localhost:8000/static/js/2.d6390d93.chunk.js:2:186427)
    at x (http://localhost:8000/static/js/2.d6390d93.chunk.js:2:186570)
    at http://localhost:8000/static/js/2.d6390d93.chunk.js:2:186716
    at T (http://localhost:8000/static/js/2.d6390d93.chunk.js:2:186802)
    at P (http://localhost:8000/static/js/2.d6390d93.chunk.js:2:187251)

I have no idea what is going wrong here... Thank you in advance for any help!

EDIT: I suppose there is some problem with react-router-dom...

I discovered what was the reason... The problem is that I was using BrowserRouter from react-router-dom. Instead, I should use HashRouter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM