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

Duplicate requests are sent when use transformItems #1037

Closed
phidang0810 opened this issue Mar 4, 2018 · 4 comments
Closed

Duplicate requests are sent when use transformItems #1037

phidang0810 opened this issue Mar 4, 2018 · 4 comments

Comments

@phidang0810
Copy link

Hi guy, I want report a bug. I'm using react-router v4, when I add widget RefinementList with transformItems property to sort items, duplicate request are send to algolia. More detail, you can see https://codesandbox.io/s/43k243yqlx

@samouss
Copy link
Collaborator

samouss commented Mar 4, 2018

Hi @phidang0810, thanks for reporting the issue.

It's a known problem on our side, we trigger a new request when the props aren't shallow equal. In your example there is a new function create on every render. It means that the props of the widget aren't shallow equal on every render.

You can avoid this issue by passing always the same reference to the transformItems function.

@samouss samouss closed this as completed Mar 4, 2018
@phidang0810
Copy link
Author

Could you give me a example for this?

@samouss
Copy link
Collaborator

samouss commented Mar 5, 2018

Yes sure, I wasn't able to give you an example since I had some trouble with CodeSandbox. But now it's good, you can find your example updated on CodeSandbox.

Let me know how it goes 😉

@phidang0810
Copy link
Author

Great. Thank you :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants