search

Home  >  Q&A  >  body text

javascript - react-router V4 BrowserRouter page refresh problem?

The picture below shows the explanation of the BrowserRouter->forceRefresh attribute in the official document. However, if forceRefresh is set to false, the page is still refreshed and the previous state cannot be shared through react-redux. It is ok to replace BrowserRouter with HashRouter. , looking for answers?

I found the answer, it’s a question about my understanding of this thing!
I thought that just modifying window.history can directly change the rendering of React. In fact, this is not the case. react-router has its own history and needs to be operated through its own history; modify the window directly. .history does not cause react to re-render, but directly refreshes the page (an illusion caused by configuring HTML5 History mode);

PHP中文网PHP中文网2765 days ago1154

reply all(1)I'll reply

  • 大家讲道理

    大家讲道理2017-07-05 10:52:48

    forceRefresh is false only to ensure that the page is not refreshed as a whole

    reply
    0
  • Cancelreply