Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(InstantSearch): remove useless walk/duplicate request (#4127)
**Summary** This PR removes a useless walk on the indices to apply the `SearchParameters`, it also removes a useless duplicate request (since we walk two times, we call search two times). At the `init` step we walk on the tree of indices to create each instance with their `uiState` and `SearchParameters`. It means that the state is already set, we don't have to trigger another walk. The extra walk was called with the result of `read` which is not correct. Inside the constructor we already merge both `initialUiState` & `read`. If an `initialUiState` is present with refinements they are all overridden by `read`. With Storybook we mock the router to always return an empty object. It means that we always remove the `initialUiState` (see below). You can also see the difference for the duplicate request on the e-commerce example. Here is the [link](https://5d81f53123e91200085f41ae--instantsearchjs.netlify.com/examples/e-commerce/) for the version prior to this PR. Open the DevTools you'll notice two identical requests on start. Here is the [link](https://deploy-preview-4127--instantsearchjs.netlify.com/examples/e-commerce/) for the version with this PR. Open the DevTools you'll notice only one request on start. **Before** ![Screenshot 2019-09-17 at 15 37 36](https://user-images.githubusercontent.com/6513513/65046859-ac764d00-d961-11e9-9b7f-f76dae19fa28.png) You can check the live version on [Storybook](https://5d81f53123e91200085f41ae--instantsearchjs.netlify.com/stories/?path=/story/currentrefinements--with-refinementlist). **After** ![Screenshot 2019-09-17 at 15 38 57](https://user-images.githubusercontent.com/6513513/65046865-af713d80-d961-11e9-9c54-ce9c10878aaf.png) You can check the live version on [Storybook](https://deploy-preview-4127--instantsearchjs.netlify.com/stories/?path=/story/currentrefinements--with-refinementlist).
- Loading branch information