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

194
Views
función de utilidad con useCallback

Tengo una función simple con useCallback en tres partes de mi aplicación para configurar una imagen:

 const myLittleFunction = useCallback((image: string | undefined) => { mySetState(image) }, [ mySetState, ])

esta función se utiliza para recuperar una imagen de un componente secundario:

 <MyChildComponent setImage={setPickerResponse} />

Pero como tengo 3 veces el mismo en tres lugares diferentes, ¿cómo podría convertirlo en una sola función de utilidad?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Creo que es posible que deba mover el STATE y la función useCallback en un enlace personalizado, y puede usarlo en varios lugares.

Ex:

 export default () => { const [myState, setMyState] = useState('value here') const myLittleFunction = useCallback((image: string | undefined) => { mySetState(image) }, [ mySetState, ]) return { myState, setMyState, myLittleFunction, } }
about 4 years ago · Santiago Trujillo 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!