Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce initialUiState option (#4074)
**Summary** This PR introduces the `initialUiState` option at the `InstantSearch` level. The option allows users to provide an `uiState` used for the initial request. Only for the **initial request**. I've chosen to name the option `initialXXX` rather than `uiState` to have a clear intent. At some point, we might want to introduce the concept of controlled state (like React InstantSearch) that could use the option `uiState`. At the moment the type definitions are incorrect. We have only one type that defines the `uiState` but we have to define two different types. The first is one is the "global" `uiState` and the second one is the "local" to each index. The "global" `uiState` is built on multiple "local" `uiState`. We'll update the definition in a separate PR. **Usage** ```js const search = instantsearch({ // ... initialUiState: { instant_search: { query: "Apple" }, instant_search_price_asc: { refinementList: { brand: ["Apple"] } } } }); ``` Checkout the example on [Storybook](https://deploy-preview-4074--instantsearchjs.netlify.com/stories/?path=/story/instantsearch--with-initialuistate).
- Loading branch information