Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Detect page reload on react (the history keeps the url before the reload action)

I'm having some issues with a tab component in multiple instances inside the same page. I would like some sort of page reload detection to be able of clearing the history. This is my prefilter function and click tab function when someone reloads:

const onTabClick = (tabId, tabHead) => {
    const state = !tabSelected;
    toggleTabSelected(tabId);
    history.push(
      `${location.pathname}?tab=${tabId}`,

      {
        shallow: true,
      }
    );
  };


 const preSelect = () => {

    if (values.tab) {
      let queryString = values.tab.toString();
      let selectedTab = Number(queryString) - 1;
      const allTabs = props.tabs;

      toggleTabSelected(queryString);
      toggleMobSelected(queryString);

 
    } else {
     
      toggleTabSelected(firstTab);
      toggleMobSelected(firstTab);
    }
  };

  useEffect(() => {
    preSelect();
  }, [tabSelected, mobSelected]);

The problem with this code is when I reload the page, the history keeps the url of the last tab that was open, while I would like to reset it. Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!