2

I would like to find out if it is possible to configure the React Native Fast Refresh to only reload the current page in case imported files are modified. I'm working on an app that has many sequential pages and when the Fast Refresh reloads the entire app, I have to navigate many page to get back to the page I'm working on.

Any suggestions greatly appreciated.

checkmate711
  • 3,301
  • 2
  • 35
  • 45

1 Answers1

0

call the reload method to tell the browser to reload the current page:

window.location.reload(false);

This method takes an optional parameter which by default is set to false. If set to true, the browser will do a complete page refresh from the server and not from the cached version of the page. As React uses JavaScript at its core, therefore you can use vanilla JavaScript whenever and however you want.

location.reload method inside of a React component:

import React from 'react';

function App() {
  
  function refreshPage() {
    window.location.reload(false);
  }
  
  return (
    <div>
      <button onClick={refreshPage}>Click to reload!</button>
    </div>
  );
}

export default App;
NL_Dev
  • 111
  • 6