Skip to content
Discussion options

You must be logged in to vote

You could use the following type:

import { type SetValues } from 'nuqs'

const updateOrganizationSearchFn = useCallback<SetValues<ParsersType>>(
  (args =>
    updateOrganizationSearchParams(args),
  [updateOrganizationSearchParams]
);

Note that:

  • Unless you plan to await things, there is no need to add async to the callback definition (the state updater function already returns a Promise)
  • Forwarding the args as-is allows using the whole API of the state updater function (passing a partial object of values, or a function to access the previous values)
  • You'll want to add the state updater function to the dependency array to recreate your custom callback when it changes (that would be when …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Kavan72
Comment options

Answer selected by Kavan72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants