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

Accept undefined on onSuccess/onError #86

Open
fsmaia opened this issue Jul 25, 2022 · 2 comments · May be fixed by #87
Open

Accept undefined on onSuccess/onError #86

fsmaia opened this issue Jul 25, 2022 · 2 comments · May be fixed by #87

Comments

@fsmaia
Copy link

fsmaia commented Jul 25, 2022

When receiving onSuccess/onError parameters externally, it's very common to handle it as optional, as in the following example:

type Props = {
  onSuccess?: (data: ...) => void;
};

const Component: React.FC<Props> = ({ onSuccess }) => {
  const { ... } = useAsync(..., [...], { onSuccess });
};

In the current implementation, for this scenario, the default onSuccess (noop) will be replaced with undefined:
https://github.com/slorber/react-async-hook/blob/master/src/index.ts#L128

@fsmaia fsmaia linked a pull request Jul 26, 2022 that will close this issue
@fsmaia fsmaia changed the title Accept undefined on onSuccess/onError Accept undefined on onSuccess/onError Jul 26, 2022
@Larisa00dila
Copy link

Hey

@pig800509
Copy link

my another answer

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

Successfully merging a pull request may close this issue.

3 participants