简体   繁体   中英

How to detect that page has been reloaded Reactjs?

There is stepper of pages with steps 1 2 3. If a page reloads on the second or third step, it has to redirect to the first step.

How can I detect that page has been reloaded?

You can catch page load when componentDidMount of your root component is fired :

class App extends React.Component {
  constructor(props) {
    super(props);
  }

  componentDidMount() {
    // do something
  }

}

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