Skip to content

Accept undefined on onSuccess/onError #86

Open
@fsmaia

Description

@fsmaia

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions