Skip to content

Commit

Permalink
Prevent excessive re-renders
Browse files Browse the repository at this point in the history
  • Loading branch information
smikhalevski committed Apr 30, 2024
1 parent 6794d71 commit fab176c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/useExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ export function useExecutor(
useDebugValue(executor, toJSON);

useEffect(() => {
const getVersion = () => executor.version;
const provideVersion = (latestVersion: number) => Math.max(latestVersion, executor.version);

const deactivate = executor.activate();
const unsubscribe = executor.subscribe(() => {
setVersion(getVersion);
setVersion(provideVersion);
});

setVersion(getVersion);
setVersion(provideVersion);

return () => {
unsubscribe();
Expand Down

0 comments on commit fab176c

Please sign in to comment.