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

181
Views
React component sends API Calls whenever loads

React component sends API call again whenever the homepage component loads with default empty values… I want whenever someone go to the settings page and came back without changes in settings, no new API Call will be sent. But if the user came from settings page after changing settings, then a new API Call will be sent according to changes… I don't want to use Session or local storage… Because it's a random User API, so if I store there it would not be change after user reloads the Page.

  const users = useSelector((state) => state.users);
  const loading = useSelector((state) => state.loading);
  const search = useSelector((state) => state.search);
  const nationlity = useSelector((state) => state.nationlity);
  const [hasMore, setHasMore] = useState(true);

  useEffect(() => {
    if (nationlity) {
      fetchUseresWithNationality(nationlity);
    } else {
      fetchUser();
    }
  }, []);
  const loadMoreUsers = () => {
    if (users.length <= 999) {
      if (nationlity) {
        fetchMoreUseresWithNationality(nationlity);
      } else {
        fetchMoreUsers();
      }
    } else {
      setHasMore(false);
    }
  };
  return (<>My Content</>)
}; 
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!