Open fsmaia opened 2 years ago
When receiving onSuccess/onError parameters externally, it's very common to handle it as optional, as in the following example:
onSuccess
onError
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
noop
undefined
Hey
my another answer
When receiving
onSuccess
/onError
parameters externally, it's very common to handle it as optional, as in the following example:In the current implementation, for this scenario, the default
onSuccess
(noop
) will be replaced withundefined
: https://github.com/slorber/react-async-hook/blob/master/src/index.ts#L128