This repository has been archived by the owner on Dec 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ssr): avoid duplicate serializing (#2726)
* fix(ssr): avoid duplicate serializing Response of `findResultsState` (and `resultsState` prop) before: ```js const resultsState = { content: SearchResults(state: searchParameters, results: rawResults), state: searchParameters, _originalResponse: { results: rawResults }, }; ``` Note that `SearchResults` has the properties `_rawResults` & `_state`. This means that when we serialize, we are retrieving the original response and state twice. Then on further searching, I also find that we don't need to serialize the `SearchResults` object at all, since only the raw response and state is used. I modified this to be more consistent and no longer have duplication: ```js const resultsState = { state: searchParameters, rawResults, }; ``` The `SearchParameters` object gets serialized without issue, as before. This change in shape has of course also an impact on the shape of `resultsState`, the prop, but that is fine, since it was previously typed as `any`. To be able to type it correctly, I had to add `@types/algoliasearch` & update `algoliasearch-helper` for typescript though. This was initially noticed by @cloakedninjas, thanks! * empty commit for CI
- Loading branch information
Showing
8 changed files
with
219 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.