Skip to content

Commit e29c6b3

Browse files
authored
Provide shouldRefetch option to prevent refetching of static queries
1 parent 29158cd commit e29c6b3

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/withStaticQuery.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,14 @@ export default function withStaticQueryContainer(config) {
1616

1717
componentWillReceiveProps(nextProps) {
1818
const { query } = nextProps;
19-
this.fetch(query);
19+
20+
if (config.shouldRefetch && config.shouldRefetch(nextProps)) {
21+
this.fetch(query);
22+
}
23+
24+
if (!config.shouldRefetch) {
25+
this.fetch(query);
26+
}
2027
}
2128

2229
componentDidMount() {

0 commit comments

Comments
 (0)