Skip to content

Commit

Permalink
doc: Add deprecation notice to withAwaitAction
Browse files Browse the repository at this point in the history
  • Loading branch information
bmaximilian committed Aug 27, 2022
1 parent 545b826 commit a916e5b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/withAwaitAction.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('withAwaitAction', () => {
return null;
}
}

const TestComponent = connect()(withAwaitAction(RawTestComponent));

const fullComponent = (
Expand Down Expand Up @@ -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);
});
});
1 change: 1 addition & 0 deletions src/withAwaitAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface WithAwaitAction<S extends Action = Action> {
/**
* 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
*/
Expand Down

0 comments on commit a916e5b

Please sign in to comment.