algolia / react-instantsearch

⚡️ Lightning-fast search for React and React Native applications, by Algolia.
https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react/
MIT License
1.97k stars 386 forks source link

feat(useInstantSearch): expose status & error #3645

Closed Haroenv closed 1 year ago

Haroenv commented 1 year ago

Summary

Introduces status and error in the response of useInstantSearch, as well as a new option on useInstantSearch to indicate errors in the search lifecycle should be caught.

built on top of https://github.com/algolia/instantsearch.js/pull/5127

Result

function Status() {
  const { status, error } = useInstantSearch({ catchError: true });

  return (
    <>
      <span>Search status: {status}</span>
      {error && <span>a search error occurred: {error.message}</span>}
    </>
  );
}

FX-1769

codesandbox-ci[bot] commented 1 year ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit bd7114161de42223ea66461ecc408e3634575165:

Sandbox Source
react-instantsearch-app Configuration
hooks-example Configuration
netlify[bot] commented 1 year ago

Deploy Preview for react-instantsearch ready!

Name Link
Latest commit bd7114161de42223ea66461ecc408e3634575165
Latest deploy log https://app.netlify.com/sites/react-instantsearch/deploys/633ac5da916c260008314565
Deploy Preview https://deploy-preview-3645--react-instantsearch.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.