How to use the useFrom hook to override the resource URL of useOne alone #3938
Replies: 1 comment
-
const { formProps, saveButtonProps } = useForm<Account, HttpError, AccountUpdates>({
redirect: false,
submitOnEnter: true,
queryOptions: {
// Here's how you disable the query or run conditionally, check react-query docs for more available
// options
enabled: false
}
})
// here's a separate mutation, there's also an async method present, very useful if you need
// to run multiple mutations as one operation, else u would be forced to use the onSuccess,
// and the promise callback nesting will get ungly
const { mutate: addOrganizationUser, isLoading: addingOrgUser } = useCreate<
OrganizationUser,
HttpError,
NewOrganizationUser
>()
function handleOnUserAdd() {
addOrganizationUser(
{
resource: 'identity/v1/OrganizationUsers',
values: newOrganizationUser
},
{
onSuccess: res => {
// if needed
},
onError: err => {
// custom error
message.error(`Failed to create user: ${err.statusCode}`)
}
}
)
}
// query options are present on everything react-query related (review their [docs](https://tanstack.com/query/v4/docs/reference/))
queryOptions: {
// Here's how you disable the query or run conditionally, check react-query docs for more available
// options
enabled: false // => can be smt like this too Boolean(activeOnlyWhenIwant)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
omeraplak
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
P-CODE
Beta Was this translation helpful? Give feedback.
All reactions