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

103
Views
How to pass function as prop to a child component in React

So I am wondering if it is possible to send the handleDictionaryResponse and handlePhotosResponse functions as props to the component ๐Ÿ™๐Ÿพ


function handleDictionaryResponse(response) {
  setData(response.data[0]);
}

function handlePhotosResponse(response) {
  setPhotos(response.data.photos);
}

function handleSearch(event) {
  event.preventDefault();
  let dictionaryApiUrl = `https://api.dictionaryapi.dev/api/v2/entries/en/${keyword}`;
  axios.get(dictionaryApiUrl).then(handleDictionaryResponse);

  let photosApiKey = `563492ad6f917000010000010a8428d27f1b43e6bc66cfe662ea13df`;
  let photosApiUrl = `https://api.pexels.com/v1/search?query=${keyword}&per_page=9`;
  let headers = { Authorization: `Bearer ${photosApiKey}` };
  axios.get(photosApiUrl, { headers: headers }).then(handlePhotosResponse);
}

function updateKeywordDetails(event) {
  setKeyword(event.target.value);
}

return (
    <Body property={data} />
  </div>
);
}
about 4 years ago ยท Juan Pablo Isaza
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!