heroku / react-refetch

A simple, declarative, and composable way to fetch data for React components

Home Page:https://blog.heroku.com/react-refetch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multiple callbacks when using "then"

luke-unifymonitor opened this issue · comments

commented

I'm using "then" to transform the response.

When combined with a refreshInterval it causes multiple requests if the props change.

Example in this code sandbox....

https://codesandbox.io/s/xrzrp27w4q

Click "Foo 1" and it calls api/1 every x seconds
Click "Foo 2" and it calls api/2 every x seconds with...but still calls api/1

That code sandbox doesn't seem to be using then or refreshInterval. Your description also doesn't seem to be using then, two clicks. Can you please clarify?

commented

Hi Ryan,

Can you have another look? I've placed all the code in index.js now so should be able to see it all from the default view.

https://codesandbox.io/s/xrzrp27w4q

Thanks, Luke

Thanks, definitely some kind of bug there. I haven't gotten a chance to dig into to see exactly what's wrong, but will mark this issue as a bug and will investigate more later (or if someone beats me to it, that's welcome :) )

I'm seeing this as well. My workaround was just to use another HOC that transformed the props after.