cult-of-coders / grapher-react

Provides easy to use React Components that are suitable for grapher package.
https://atmospherejs.com/cultofcoders/grapher-react
38 stars 19 forks source link

When query params are updated new and old data is mixed up in withStaticQuery #30

Open Sergeeeek opened 6 years ago

Sergeeeek commented 6 years ago

I noticed a bug in withStaticQuery where if you update the query without remounting the component it will still fetch old data and will alternate between new and old data which causes all sorts of problems.

I think it's related to these lines:

https://github.com/cult-of-coders/grapher-react/blob/0d7e8c3795927d9306743f136dad8954aa7d6fe4/lib/withStaticQuery.js#L16-L30

In componentWillReceiveProps interval should be reset and started with a new query from props.