react-async-hook
react-async-hook copied to clipboard
Accept `undefined` on `onSuccess`/`onError`
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
Hey