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

129
Views
¿Puedo pasar accesorios a un componente React desde una función general?
 import B from './B.js'; const Test = () => { async function getResults() { await axios .get(`http://localhost:2000/?url=${link}`) .then((response) => { <B data={response.data} /> }); } return ( <> <div> <button onClick={getResults}> Click </button> </div> </> )

Estaba tratando de pasar los datos de axios como accesorios a mi componente B. Pero en la consola obtuve un valor indefinido. Cómo resolver este problema. ¿Debo pasar los accesorios dentro del área de devolución del componente de prueba solamente?

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

0

Necesita usar useState para almacenar datos

 import B from './B.js'; import { useState } from 'react' const Test = () => { const [data, setData] = useState({}) async function getResults () { await axios .get(`http://localhost:2000/?url=${link}`) .then((response) => { setData(response.data) }); } return ( <> <div> <button onClick={getResults}> Click </button> <B data={data} /> </div> </> ) }
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!