Created
March 8, 2024 21:46
-
-
Save gregfenton/f29d6aea5ff186d019203527473481a0 to your computer and use it in GitHub Desktop.
Algolia react-instantsearch code not working correctly
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
<InstantSearch | |
indexName={ALGOLIA_INDEX_PROJECT} | |
searchClient={searchClient} | |
routing={routing} | |
future={{ | |
preserveSharedStateOnUnmount: true, | |
}} | |
onStateChange={({uiState, setUiState}) => { | |
if (firstRender.current) { | |
firstRender.current = false; | |
if (myUiStateCache) { | |
console.log(`firstRender USE CACHE:`, myUiStateCache); | |
setUiState({...myUiStateCache}); | |
} else { | |
console.log(`firstRender USE INITIAL VALUES:`, uiState); | |
setUiState(uiState); | |
} | |
} else { | |
updateMyUiStateCache(uiState); | |
setUiState(uiState); | |
} | |
}} | |
> | |
<ProjectListResults /> | |
</InstantSearch> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code snippet to go with the issue posted on Algolia Community