diff --git a/src/withAwaitAction.spec.tsx b/src/withAwaitAction.spec.tsx index 17d60f0..c8f8fcc 100644 --- a/src/withAwaitAction.spec.tsx +++ b/src/withAwaitAction.spec.tsx @@ -56,6 +56,7 @@ describe('withAwaitAction', () => { return null; } } + const TestComponent = connect()(withAwaitAction(RawTestComponent)); const fullComponent = ( @@ -221,4 +222,27 @@ describe('withAwaitAction', () => { console.error = errorHandler; // eslint-disable-line no-console }); + + // Not easily possible when rendering class components + // eslint-disable-next-line jest/no-disabled-tests + it.skip('Should not re-initialize when storeAwait when component re-renders', async () => { + let previousStoreAwait; + let nextStoreAwait; + + const { rerender } = render( + createStoreAwaitComponents(storeAwait => { + previousStoreAwait = storeAwait; + }, jest.fn()), + ); + + rerender( + createStoreAwaitComponents(storeAwait => { + nextStoreAwait = storeAwait; + }, jest.fn()), + ); + + expect(previousStoreAwait).toBeDefined(); + expect(nextStoreAwait).toBeDefined(); + expect(previousStoreAwait).toBe(nextStoreAwait); + }); }); diff --git a/src/withAwaitAction.tsx b/src/withAwaitAction.tsx index 6446b58..ecf3a3f 100644 --- a/src/withAwaitAction.tsx +++ b/src/withAwaitAction.tsx @@ -18,6 +18,7 @@ export interface WithAwaitAction { /** * Creates a hoc that attaches the storeAwait method to the wrapped component * + * @deprecated - please use "useMemo" instead * @param WrappedComponent - The wrapped component * @returns - The enhanced component with storeAwait prop */