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

165
Views
Hoc React Hook "useEffect" no se puede llamar dentro de una devolución de llamada

Estoy tratando de usar un componente HOC en React con un componente funcional, pero cuando uso ganchos sigo recibiendo el error React Hook "useEffect" cannot be called inside a callback. ¿Qué estoy haciendo mal y cómo puedo solucionar esto?

 const HOC = (WrappedComponenet, entity) => { return function () { const [data, setData] = useState([]); const [term, setTerm] = useState(""); useEffect(() => { fetch(`https://jsonplaceholder.typicode.com/${entity}`) .then((res) => res.json()) .then((data) => setData(data)); }, []); let filteredData = data.slice(0, 10).filter((d) => { if (entity === "users") { const { name } = d; return name.indexOf(term) >= 0; } if (entity === "todos") { const { title } = d; return title.indexOf(term) >= 0; } }); return <WrappedComponenet data={filteredData} />; }; };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Echa un vistazo a este fragmento:

 const HOC = (WrappedComponenet, entity) => { function MyCustomComponent() { const [data, setData] = useState([]); const [term, setTerm] = useState(""); useEffect(() => { fetch(`https://jsonplaceholder.typicode.com/${entity}`) .then((res) => res.json()) .then((data) => setData(data)); }, []); let filteredData = data.slice(0, 10).filter((d) => { if (entity === "users") { const { name } = d; return name.indexOf(term) >= 0; } if (entity === "todos") { const { title } = d; return title.indexOf(term) >= 0; } }); return <WrappedComponenet data={filteredData} />; }; return <MyCustomComponent/> };
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!