Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarification needed: should useApi export full loader or should useLoaderSuccess JSDoc be updated? #49

Open
VldMrgnn opened this issue Oct 2, 2024 · 0 comments

Comments

@VldMrgnn
Copy link
Collaborator

VldMrgnn commented Oct 2, 2024

Currently, the JSDoc for useLoaderSuccess suggests using the loader from useApi, but useApi does not return the full loader object, which causes confusion when trying to use useLoaderSuccess with useApi.

return { ...loader, trigger, action };
vs.
const { loader, trigger } = useApi(createUser);

There seem to be two possible approaches to resolve this:

  1. Export the full loader object so it can be used seamlessly with useLoaderSuccess. This would look like:
return { ...loader, loader, trigger, action };
  1. Update the JSDoc for useLoaderSuccess. For example:
/**
 * useLoaderSuccess 
 * ....
 * const View = () => {
 *   const { trigger } = useApi(createUser);
 *   const loader = useLoader(createUser); // Use useLoader to get the full loader
 *   const onSubmit = () => {
 *     trigger({ name: 'bob' });
 *   };
 * ```

I think this issue should be addressed in some manner to avoid confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant