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

213
Views
Llame a useQuery api cuando se hace clic en el botón

Usando la función de recuperación useQuery, coloque la función de recuperación en el botón, y cuando se hace clic en el botón, los datos se recuperan nuevamente a través de la llamada API. Quería, pero no sucedió.

 function SeedMaterialDetails(id: number) { return axios.get(`/detail/${id}`, { headers: { "Content-Type": "application/json", }, }) } const { data: SeedDetail, refetch: SeedDetaiList } = useQuery( ["seedId", seedId], () => SeedMaterialDetails(seedId), { onSuccess: (data) => { console.log(data); }, onError: () => {}, onSettled: (data, context) => { } } ); const [value, setValue] = useState(""); const onChangeValue = (event: event: React.ChangeEvent<HTMLInputElement>) => { setValue(event.target.value) } const handleMaterialSave = useCallback( (event: React.ChangeEvent<FormEvent>) => { event.preventDefault(); console.log([value]); SeedDetaiList(); }, [SeedDetaiList] ); return ( <> <input type="text" value={value} onChange={onChangeValue} <button onClick={handleMaterialSave}>저장</button> </> )

Puse la función de recuperación en handleMaterialSave y cuando el botón funciona, pensé que la api useQuery llamaría pero no responde.

Quiero volver a llamar a la API useQuery cuando hago clic en el botón, pero ¿cómo lo hago?

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!