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

262
Views
¿Cómo crear una abreviatura para useDispatch con una acción específica dentro? Mecanografiado

Quiero usar const dispatch = useAppDispatch()

Y luego dispatch(edit(xxxxxxx))

Me gustaría tener algo como const edit = useAppDispatch(edit(xxxxxxx))

Y luego simplemente edit(xxxxxxx) en el código

Pero no funciona. ! ¡ayuda!

Recibo el error Expected 0 arguments, but got 1

O aparece el error React Hook "useAppDispatch" cannot be called at the top level. React Hooks must be called in a React function component or a custom React Hook function si intento definir una abreviatura para useAppDispatch en algún lugar fuera de la función, que es lo que quiero hacer. No definirlo dentro de cada componente.

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

0

La respuesta correcta aquí es crear una función que se despacha cuando se llama:

 const dispatch = useAppDispatch(); const handleClick = () => dispatch(edit(someArgument));

Esto debe declararse dentro del cuerpo del componente de la función.

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!