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

246
Views
cambiar el valor de la variable con axios, useeffect y usestate

Soy novato aquí, estoy atascado. quiero cambiar el valor de falso a verdadero, para dejar de brillar cuando los datos se carguen correctamente.

tengo una acción como esta

 import axios from "axios"; import { CONSTANT_LINK } from "./constants"; import { GET } from "./constants"; import { ERROR } from "./constants"; import { connect } from 'react-redux'; export const addData = () => { return (dispatch) => { axios .get(CONSTANT_LINK) .then((res) => { dispatch(addDataSuccess(res.data)); }) .catch((err) => { dispatch(errorData(true)); console.log("error"); }); }; }; const addDataSuccess = (todo) => ({ type: GET, payload: todo, }); const errorData = (error) => ({ type: ERROR, payload: error, });

y esta es mi página de inicio que influye en este asunto

 const [shimmerValue, setShimmerValue] = useState(false) useEffect(() => { setShimmerValue(true) dispatch(addData()); }, []); <ShimmerPlaceholder visible={shimmerValue} height={20}> <Text style={styles.welcomeName}>Welcome,Barret</Text> </ShimmerPlaceholder>

no entiendo como funciona

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Puedes pasar una devolución de llamada como esta

 const [shimmerValue, setShimmerValue] = useState(false); const updateShimmerValue = () => { setShimmerValue(true); } useEffect(() => { // setShimmerValue(true) // remove this from here dispatch(addData(updateShimmerValue)); // pass callback as param here }, []);

Llamada de devolución de llamada aquí como

 export const addData = (callback) => { return (dispatch) => { axios .get(CONSTANT_LINK) .then((res) => { .... callback(); // trigger callback like this here }) .catch((err) => { .... }); }; };
about 4 years ago · Juan Pablo Isaza Report

0

puedes usarlo:

 const [shimmerValue, setShimmerValue] = useState(false) useEffect(() => { setState(state => ({ ...state, shimmerValue: true })); dispatch(addData()); }, [shimmerValue]);
about 4 years ago · Juan Pablo Isaza Report
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!