diff --git a/src/Get.test.tsx b/src/Get.test.tsx index 35d69477..ed85d4a6 100644 --- a/src/Get.test.tsx +++ b/src/Get.test.tsx @@ -567,23 +567,14 @@ describe("Get", () => { .persist(); const children = jest.fn(); children.mockReturnValue(
); - const resolve = a => a; - /** - * A new instance of RestfulProvider is created on every rerender. - * This will create a new resolve function every time forcing Get to - * refetch. - * In a real app, only Get would be rerendered so resolve would be the - * same on every new render. To mimic that behavior, resolve is created - * ahead so Get will get the same instance on every rerender. - */ const { rerender } = render( - + {children} , ); times(10, i => rerender( - + {children} , ), @@ -600,14 +591,13 @@ describe("Get", () => { .persist(); const children = jest.fn(); children.mockReturnValue(
); - const resolve = a => a; const { rerender } = render( - + data}> {children} , ); rerender( - + data}> {children} , ); @@ -620,9 +610,8 @@ describe("Get", () => { .reply(200, () => ++apiCalls); const children = jest.fn(); children.mockReturnValue(
); - const resolve = a => a; const { rerender } = render( - + {children} , ); @@ -630,7 +619,7 @@ describe("Get", () => { .get("/") .reply(200, () => ++apiCalls); rerender( - + {children} @@ -647,14 +636,13 @@ describe("Get", () => { .persist(); const children = jest.fn(); children.mockReturnValue(
); - const resolve = a => a; const { rerender } = render( - + {children} , ); rerender( - + {children} , ); @@ -674,9 +662,9 @@ describe("Get", () => { {children} , ); - const newResolve = a => a; + const newResolve = () => "hello"; rerender( - + {children} diff --git a/src/Get.tsx b/src/Get.tsx index 402d39a0..27ecb08b 100644 --- a/src/Get.tsx +++ b/src/Get.tsx @@ -170,7 +170,8 @@ class ContextlessGet extends React.Component< base !== this.props.base || parentPath !== this.props.parentPath || path !== this.props.path || - resolve !== this.props.resolve + // both `resolve` props need to _exist_ first, and then be equivalent. + (resolve && this.props.resolve && resolve.toString() !== this.props.resolve.toString()) ) { if (!this.props.lazy) { this.fetch();