Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

feat(hooks): introduce useNumericMenu #3237

Merged
merged 3 commits into from
Dec 10, 2021

Conversation

francoischalifour
Copy link
Member

This adds useNumericMenu to our Hooks collection.

API

This hook is a bridge to connectNumericMenu.

Usage

function NumericMenu(props) {
  const { items, refine } = useNumericMenu(props);

  return /* ... */;
}

function App(props) {
  return (
    <InstantSearch {...props}>
      <NumericMenu
        attribute="price"
        items={[
          { label: 'All' },
          { label: 'Less than 500$', end: 500 },
          { label: 'Between 500$ - 1000$', start: 500, end: 1000 },
          { label: 'More than 1000$', start: 1000 },
        ]}
      />

      {/* ... */}
    </InstantSearch>
  );
}

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 10, 2021

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 b957fd3:

Sandbox Source
react-instantsearch-app Configuration
routing-basic Configuration
hooks-example Configuration

@netlify
Copy link

netlify bot commented Dec 10, 2021

✔️ Deploy Preview for react-instantsearch ready!

🔨 Explore the source changes: c8d5b01

🔍 Inspect the deploy log: https://app.netlify.com/sites/react-instantsearch/deploys/61b3280681511700074eb04e

😎 Browse the preview: https://deploy-preview-3237--react-instantsearch.netlify.app

@netlify
Copy link

netlify bot commented Dec 10, 2021

✔️ Deploy Preview for react-instantsearch ready!

🔨 Explore the source changes: b957fd3

🔍 Inspect the deploy log: https://app.netlify.com/sites/react-instantsearch/deploys/61b36bef98e2f00008c3f16e

😎 Browse the preview: https://deploy-preview-3237--react-instantsearch.netlify.app

Copy link
Member

@dhayab dhayab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I only have comments unrelated to the feature on my side.

examples/hooks/App.tsx Outdated Show resolved Hide resolved
examples/hooks/App.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

examples/hooks/App.tsx Outdated Show resolved Hide resolved
<div
className={cx(
'ais-NumericMenu',
hasNoResults && 'ais-NumericMenu--noRefinement',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use canRefine here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not returned by the connector unfortunately. Let's maybe add that in IS.js in a minor, and remove hasNoResults in the next major?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good, I didn't know this widget was missed

@francoischalifour francoischalifour merged commit e3056c9 into master Dec 10, 2021
@francoischalifour francoischalifour deleted the feat/hooks-useNumericMenu branch December 10, 2021 16:43
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.

None yet

3 participants