Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

179
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda