0

I have problem understanding this piece of code. How i can pass the id and data ?

function usePutCompany(id) {
  const [putCompany] = useMutation<any, any, any>(
    (data) => ApiCall.Company.put(id, data),
    {
      onSuccess() {
        queryCache.invalidateQueries('company')
        queryCache.refetchQueries('company')
      },
      throwOnError: true,
    },
  )

  return putCompany
}

1 Answer 1

2

id is a parameter to the custom hook, and data is a parameter to the function returned by the hook. You would use this custom hook like this:

function MyComponent() {
  const putCompany = usePutCompany(1)

  return <Button onClick={() => putCompany(data) />
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.