Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

fix(hooks): apply initial search parameters in useConnector #3276

Merged
merged 5 commits into from
Jan 24, 2022

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Jan 24, 2022

Summary

the state of "results" when not doing server side rendering isn't aware of the widgets yet. This is incorrect, and thus we need to call getWidgetSearchParameters before rendering.

This is still wrong when the state has been set by another widget, in the case of breadcrumb/hierarchical menu. I think that can be fixed by having both widgets apply the same state (maybe the already do it, I didn't test)

Result

slower initial mount, but actually correct 馃摝

cases to test:

  • server side rendering
    • not an issue, in the case of server side rendering the helper state is saved, there's a test
  • breadcrumb
    • not yet implemented
  • current refinements
    • flashes empty state, but I don't think there's a workaround (was already the case before this PR)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 24, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 29a428b:

Sandbox Source
react-instantsearch-app Configuration
hooks-example Configuration


// Initial render state from manual `getWidgetRenderState`
expect(result.current).toEqual({
query: 'testio',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before the changes in useConnector, this is query: ''

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify

This comment has been minimized.

@netlify
Copy link

netlify bot commented Jan 24, 2022

鉁旓笍 Deploy Preview for react-instantsearch ready!

馃敤 Explore the source changes: 29a428b

馃攳 Inspect the deploy log: https://app.netlify.com/sites/react-instantsearch/deploys/61eebf5251d9160007adc543

馃槑 Browse the preview: https://deploy-preview-3276--react-instantsearch.netlify.app

@Haroenv Haroenv changed the title wip: apply initial search parameters in hooks fix(hooks): apply initial search parameters in useConnector Jan 24, 2022
@Haroenv Haroenv marked this pull request as ready for review January 24, 2022 14:35
@Haroenv Haroenv requested review from francoischalifour, a team and dhayab and removed request for a team January 24, 2022 14:35
Co-authored-by: Fran莽ois Chalifour <francoischalifour@users.noreply.github.com>
@Haroenv Haroenv merged commit f85d679 into master Jan 24, 2022
@Haroenv Haroenv deleted the fix/initial-state-hooks branch January 24, 2022 15:23
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants