Commit de00707
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).1 parent 227a2cb commit de00707
File tree
8 files changed
+186
-66
lines changed- src
- lib
- __tests__
- types
- widgets/index
- __tests__
- stories
- test/mock
8 files changed
+186
-66
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
106 | 114 | | |
107 | 115 | | |
108 | 116 | | |
| |||
139 | 147 | | |
140 | 148 | | |
141 | 149 | | |
| 150 | + | |
142 | 151 | | |
143 | 152 | | |
144 | 153 | | |
| |||
151 | 160 | | |
152 | 161 | | |
153 | 162 | | |
154 | | - | |
| 163 | + | |
| 164 | + | |
155 | 165 | | |
156 | 166 | | |
157 | 167 | | |
| |||
234 | 244 | | |
235 | 245 | | |
236 | 246 | | |
| 247 | + | |
237 | 248 | | |
238 | 249 | | |
239 | 250 | | |
| |||
411 | 422 | | |
412 | 423 | | |
413 | 424 | | |
| 425 | + | |
414 | 426 | | |
415 | 427 | | |
416 | 428 | | |
| |||
0 commit comments