Hello, if anyone has experience with react instant...
# community-help
l
Hello, if anyone has experience with react instant search, can you implement your own range slider? I find React instant search
RangeSlider
to have very bad user experience. When setting your range on more than 1 slider, the rest of the slider values keeps jumping, because it always tries to find the hit. Also you can’t select out of range values? When selecting a value that doesn’t exist in the database i get:
Copy code
Error: You can't provide min value lower than range.
In my opinion it would be much better if instead of throwing validation error, user would simply be informed that 0 hits were returned. Is there any solution to this?
j
I haven't used react-instantsearch, but at least in vue-instantsearch, you can bring in a custom range slider component. Looks like there's an equivalent in React here: https://www.algolia.com/doc/api-reference/widgets/range-slider/react/#connector
l
@Jason Bosco yeah that’s what I’m using, but the same rules apply, you still can’t select out of range values
What I mean to say can you implement your own logic and skip react instant search?
j
You could... but if you're using instantsearch in your application already, it might be hard to get custom code to play nice with the other instantsearch widgets.
Btw, I just remembered, I did use react-instantsearch once (and promptly forgot about it), to implement this demo: https://showcase-nextjs-typesense-ecommerce-store.vercel.app/ Here's how I implemented the price range slider: https://github.com/typesense/showcase-nextjs-typesense-ecommerce-store/blob/master/components/RangeSlider/RangeSlider.js
That slider doesn't seem to have the issue you mentioned. So I think setting min and max in the widget are key
l
Yes I see, there’s really no issues with one slider, but look what happens when there’s more( I know that my current dataset is very small), it’s just that it causes too much jumping.
j
Hmm, looks like the min and max are jumping around based on the results. May be try setting min to 0 and max to some high number, instead of using the number from the results?
l
@Jason Bosco yeah, I tried, I set the calorie slider min to 0, but since the lowest value in my collection is 50, anytime I select number lower than 50 I get:
j
Hmm, that doesn't sound like an error from Typesense... May be it's coming from the range slider itself? And I'm not sure why they would disallow this
l
@Jason Bosco yes, its not from typesense, its the
connectRange
api from react-instantsearch
So there is an option to use typesense rest api yourself? Like passing all the parameters and query string yourself.
j
Yeah, you can use typesense-js directly