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

148
Vistas
Enviar datos de padre a hijo devuelve un valor y luego un componente funcional indefinido

En el componente del tablero principal, recibo solicitudes de 5 matrices. Cuando los registro en la consola obtengo los datos. Cuando trato de pasar los datos a un componente secundario, los valores se vuelven indefinidos, luego los valores luego indefinidos

El salpicadero;

 const [logdata, setLogData] = useState([]) const [storageData, setStorageData] = useState([]) const [logquotation, setLogQuotation] = useState([]) const [storageQuotation, setStorageQuotation] = useState([]) const [productQuotation, setProductQuotation] = useState([]) const getLogData = () => { axios.get("http://localhost:8080/api/logisticsrecords") .then(res => { setLogData(res.data) console.log(res) }) .catch(err => console.log(err)) } const getStorageData = () => { axios.get("http://localhost:8080/api/storageshipment") .then(res =>{ setStorageData(res.data) }) .catch(err => console.log(err)) } const getLogisticsQuotation = () => { axios.get("http://localhost:8080/api/logisticsquotation") .then(res =>{ setLogQuotation(res.data) }) .catch(err => console.log(err)) } const getStorageQuotation = () => { axios.get("http://localhost:8080/api/storagequotation") .then(res =>{ setStorageQuotation(res.data) }) .catch(err => console.log(err)) } const getProductQuotation = () => { axios.get("http://localhost:8080/api/productquotation") .then(res =>{ setProductQuotation(res.data) }) .catch(err => console.log(err)) } useEffect(() => { getLogData() getStorageData() getLogisticsQuotation() getProductQuotation() getStorageQuotation() }, []) console.log("dashboard data",logdata, storageData, storageQuotation, logquotation)

En este punto, cuando registro todos los estados en la consola, obtengo los valores esperados. Pasar los valores como accesorios al componente secundario

 <DashboardHome storage={storageData} logistics = {logdata} storeQuotation = {storageQuotation} prodQuotation = {productQuotation} logisticsQuotation = {logquotation} />

Desestructuración de los valores en el componente hijo

 const DashboardHome = ({ storage, logistics, storeQuotation, prodQuotation, logisticsQuotation }) => { console.log("The dashboard logistics/storage",storage, logistics) console.log("the dashboard [quotation] data", storeQuotation, prodQuotation, logisticsQuotation) console.log(storage, "storage data") console.log("variable length is", storage) return(...)}

Lo que obtengo en la consola ingrese la descripción de la imagen aquí

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