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

fix(core/InstantSearch): update algoliaClient when it change #70

Merged
merged 2 commits into from
Apr 28, 2017

Conversation

Mystraht
Copy link
Contributor

Summary

ApiKey parameter is not changed in search query when InstantSearch component is updated with new apiKey props.
Algolia client is updated with new values if appId or apiKey is changed (at createInstantSearch.js:39) but helper in InstantSearchManager (created in InstantSearch component) is not updated.

Result

I created component that render InstantSearch with apiKey "exampleApiKey1" then i changed component state (with setTimeout for the example) to render InstantSearch again but with a new apiKey props. (exampleApiKey2)

Without my fix, ajax call is always called with exampleApiKey1

http://image.prntscr.com/image/c5a1670088ad4e7b9edfaff72ec9479b.png

With my fix, ajax get is called with exampleApiKey1 then exampleApiKey2 after rendering with the new props (see screens)

http://image.prntscr.com/image/a68d4384ff16488f83813e98b91478cb.png

Thanks

Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

This looks like a great catch, thanks a lot!

Can you add a unit test so that this doesn't degrade in the future?

@Mystraht
Copy link
Contributor Author

Thank you for this quick response, i just added the unit test

@Haroenv Haroenv requested a review from mthuret April 28, 2017 08:32
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

To me this looks good, but I'll wait for @mthuret's review before merging.

@Mystraht
Copy link
Contributor Author

Ok thanks

@mthuret
Copy link
Contributor

mthuret commented Apr 28, 2017

@Mystraht Thank you for your contribution :)

@mthuret mthuret merged commit 9e97dbd into algolia:master Apr 28, 2017
mthuret pushed a commit that referenced this pull request May 2, 2017
<a name="4.0.0-beta.5"></a>
# [4.0.0-beta.5](v4.0.0-beta.4...v4.0.0-beta.5) (2017-05-02)

### Bug Fixes

* **connectAutoComplete:** allow usage with hits from a single index (#75) ([8b3b358](8b3b358)), closes [#74](#74)
* **InstantSearch:** update algoliaClient when it change (#70) ([9e97dbd](9e97dbd))
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.

3 participants