Skip to content

Commit

Permalink
memoize mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
maciaszczykm committed Oct 18, 2024
1 parent 3988aeb commit bed3cf3
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ function EditPluralOIDCClient({
[redirectUris, setRedirectUris]
)

const m = useMemo(
() => (!provider ? useCreateProviderMutation : useUpdateProviderMutation),
[provider]
)

const attributes: OidcAttributes = useMemo(
() => ({
name,
Expand All @@ -100,12 +105,10 @@ function EditPluralOIDCClient({
refetch()
}, [onClose, refetch])

const [mutation, { loading, error }] = !provider
? useCreateProviderMutation({ variables: { attributes }, onCompleted })
: useUpdateProviderMutation({
variables: { id: provider.id, attributes },
onCompleted,
})
const [mutation, { loading, error }] = m({
variables: { id: provider?.id, attributes },
onCompleted,
})

return (
<div
Expand Down

0 comments on commit bed3cf3

Please sign in to comment.