Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda