feat(server): reset scheduleSearch only after all components mount #6650
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In Remix a bug was reported CR-8629, which said that there's an edge case happening where (not always) the hydrating DOM does not match the server DOM. This is caused by InfiniteHits that does not give hits if we are currently searching. Why are we searching? Because the
scheduleSearch
function is reset before all widgets are mounted. Until now we rely ondefer
to reset the function only once all widgets are mounted, but that's not reliable.The solution: reset
scheduleSearch
only after thechildren
of theInstantSearch
component have been mounted. For that two new private properties are added to InstantSearch:_manuallyResetScheduleSearch
(set in the useInstantSearchApi hook wheninitialResults
are set) and a new function_resetScheduleSearch
. We call this function if it exists after children have been mounted.In this test I've updated the InitializePromise synthetic test, as it was using
render
from testing-library/react, which evaluates effects, which in real server environments doesn't happen.