Skip to content
This repository was archived by the owner on Jun 11, 2021. It is now read-only.

feat(onError): introduce onError option #23

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

francoischalifour
Copy link
Owner

I'm not sure we should introduce this option until somebody needs it, so I only open this PR as a draft.

Description

This adds the onError option to catch errors while fetching suggestions.

Usage

<Autocomplete
  onError={({ state }) => {
    console.error(state.statusContext.error.message);
  }}
  getSources={() => {
    return [
      {
        getInputValue({ suggestion }) {
          return suggestion.query;
        },
        getSuggestions({ query }) {
          return Promise.reject(new Error("Can't fetch suggestions."));
        },
      },
    ];
  }}
/>

Notes

  • Perhaps onError is too generic as a name?
  • statusContext seems really close to status and context already present in the state object

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

Successfully merging this pull request may close these issues.

1 participant