Skip to content

Commit

Permalink
Removed executor memoization from useExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
smikhalevski committed Nov 25, 2024
1 parent e66bc3c commit 28ff817
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/main/useExecutor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useMemo } from 'react';
import type { Executor, ExecutorPlugin, ExecutorTask, NoInfer } from './types';
import { useExecutorManager } from './useExecutorManager';
import { useExecutorSubscription } from './useExecutorSubscription';
Expand Down Expand Up @@ -48,9 +47,7 @@ export function useExecutor(
initialValue?: unknown,
plugins?: Array<ExecutorPlugin | null | undefined>
): Executor {
const manager = useExecutorManager();

const executor = useMemo(() => manager.getOrCreate(key, initialValue, plugins), Array.isArray(key) ? key : [key]);
const executor = useExecutorManager().getOrCreate(key, initialValue, plugins);

useExecutorSubscription(executor);

Expand Down
4 changes: 1 addition & 3 deletions src/test/useExecutor.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ describe('useExecutor', () => {
});

test('returns the same executor for an array-of-primitives key', () => {
const manager = new ExecutorManager({
keySerializer: key => key,
});
const manager = new ExecutorManager();

const hook = renderHook(() => useExecutor(['xxx', 111]), {
wrapper: props => (
Expand Down

0 comments on commit 28ff817

Please sign in to comment.