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

Unable to set default sort (`defaultRefinement`) order in Hooks #3686

Closed joepio closed 1 year ago

joepio commented 1 year ago

🐛 Bug description

First off: this library is amazing, and you should feel proud.

In react-instantsearch-dom, I used the SortBy component and passed it a defaultRefinement to set a custom default sort attribute. This prop is no longer available, and I haven't yet found an alternative approach in doing the same thing.

There is a defaultValue prop in the SortBy component, though, but for some reason that does not seem to do anything.

Environment

"react-instantsearch-hooks-web": "^6.38.0",

Haroenv commented 1 year ago

The defaultValue in sortBy should be removed from the type (that's the dom property), as value is set by the library.

To set initial values you can either use routing or initialUiState

joepio commented 1 year ago

Thanks @Haroenv, that worked just fine!