Skip to content

Commit 2ede137

Browse files
authored
When polling, query should be refreshed from props
Currently, if you change the query when polling, it refetches the initial query.
1 parent 6d0bb11 commit 2ede137

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/withStaticQuery.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function withStaticQueryContainer(config) {
3030

3131
if (config.pollingMs) {
3232
this.pollingInterval = setInterval(() => {
33-
this.fetch(query);
33+
this.fetch();
3434
}, config.pollingMs);
3535
}
3636
}
@@ -40,6 +40,10 @@ export default function withStaticQueryContainer(config) {
4040
}
4141

4242
fetch(query) {
43+
if (!query) {
44+
query = this.props.query;
45+
}
46+
4347
query.fetch((error, data) => {
4448
if (error) {
4549
this.setState({

0 commit comments

Comments
 (0)