diff --git a/src/Get.test.tsx b/src/Get.test.tsx index 14a085b2..f00fa852 100644 --- a/src/Get.test.tsx +++ b/src/Get.test.tsx @@ -730,6 +730,33 @@ describe("Get", () => { ); expect(apiCalls).toEqual(2); }); + it("should refetch when queryParams changes", () => { + let apiCalls = 0; + nock("https://my-awesome-api.fake") + .get("/") + .reply(200, () => ++apiCalls) + .persist(); + nock("https://my-awesome-api.fake") + .get("/") + .query({ page: 2 }) + .reply(200, () => ++apiCalls) + .persist(); + const children = jest.fn(); + children.mockReturnValue(
); + const { rerender } = render( + + {children} + , + ); + rerender( + + + {children} + + , + ); + expect(apiCalls).toEqual(2); + }); }); describe("Compose paths and urls", () => { it("should compose the url with the base", async () => { diff --git a/src/Get.tsx b/src/Get.tsx index 837f052a..ecf06f8b 100644 --- a/src/Get.tsx +++ b/src/Get.tsx @@ -181,11 +181,12 @@ class ContextlessGet extends React.Component< } public componentDidUpdate(prevProps: GetProps) { - const { base, parentPath, path, resolve } = prevProps; + const { base, parentPath, path, resolve, queryParams } = prevProps; if ( base !== this.props.base || parentPath !== this.props.parentPath || path !== this.props.path || + queryParams !== this.props.queryParams || // both `resolve` props need to _exist_ first, and then be equivalent. (resolve && this.props.resolve && resolve.toString() !== this.props.resolve.toString()) ) {