Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(routing): manually push changed path #6385

Merged
merged 1 commit into from
Oct 9, 2024
Merged

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Oct 9, 2024

Summary

Instead of using next's router.push function, we're transitioning back to history.pushState. This works better in many edge cases as it prevents a whole page refresh and rerender.

Result

No unexpected rerenders when changing state.

Possible intended side effect of this fix is of course that any global change handlers or code running in render won't run anymore when changing instantsearch state. This can be worked around by using the onStateChange function or a middleware.

Back navigation still works as expected.

Instead of using next's `router.push` function, we're transitioning back to `history.pushState`. This works better in many edge cases as it prevents a whole page refresh and rerender.

Possible intended side effect of this fix is of course that any global change handlers or code running in render won't run anymore when changing instantsearch state. This can be worked around by using the `onStateChange` function or a middleware.

Back navigation still works as expected.
Copy link

codesandbox-ci bot commented Oct 9, 2024

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 fdd966b:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

@Haroenv Haroenv merged commit e5f0bdd into master Oct 9, 2024
14 checks passed
@Haroenv Haroenv deleted the fix/next-router-history branch October 9, 2024 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants