question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react-instantsearch react-router-3 example calling onSearchStateChange on route change

See original GitHub issue

Do you want to request a feature or report a bug?

bug

https://github.com/DeedMob/instantsearch.js/tree/v2/packages/react-instantsearch/examples/react-router

Bug: What is the current behavior?

When I use the code from the react-router 3 example whenever I try to navigate away from the page with the react-instantsearch component in it, onSearchStateChange gets called 6x and it immediately pushes over the new route.

Bug: What is the expected behavior?

I don’t expect onSearchStateChange to be called if the route pathname changes, and I expect the component to be unmounted. I also don’t expect it to be called 6 times. I should be able to navigate away from this page without the onSearchStateChange router push/replace overriding my new location

Bug: What browsers are impacted? Which versions?

I think this is an implementation/example error, not a browser error. But I experienced this on the newest Chrome build.

Feature: What is your use case for such a feature? DNA Feature: What is your proposed API entry? The new option to add? What is the behavior?

What project are you opening an issue for?

  • react-instantsearch

What is the version you are using? Always use the latest one before opening a bug issue. 3.2.1

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
mthuretcommented, Mar 27, 2017

Hi @davidfurlong,

If I understand correctly, what you want is a way to unmount widgets without having onSearchStateChange?

Is https://github.com/algolia/instantsearch.js/issues/2061 describe your issue?

1reaction
eyncommented, Mar 22, 2017

Same here - seems to happen during unmount. As a temporary fix you can set a flag in componentwillunmount and then ignore search state changes after that point.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sync your URLs with React InstantSearch - Algolia
Synchronizing your search UI with the browser URL is a good practice. It allows your users to share the current state of their...
Read more >
Components seem to trigger onSearchStateChange when ...
Hi, I've run into two issues while integrating React Instantsearch into my website, and they seem to have the same root cause.
Read more >
Algolia passing search state between different components
Im trying to get algolia instantsearch for react router 4 to render results while the <searchbox /> is in another component.
Read more >
Search with Algolia in React Native using React InstantSearch
Routing : React InstantSearch provides the necessary API to ... onSearchStateChange(nextSearchState) This function is called every time the ...
Read more >
react-instantsearch-dom examples - CodeSandbox
Learn how to use react-instantsearch-dom by viewing and forking react-instantsearch-dom example apps on CodeSandbox.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found