Skip to content

Commit

Permalink
[core] Replace a useCallback by useRef in useEventCallback (#39078)
Browse files Browse the repository at this point in the history
  • Loading branch information
romgrk authored Oct 22, 2023
1 parent 58c617e commit fdfaf64
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/mui-utils/src/useEventCallback/useEventCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ function useEventCallback<Args extends unknown[], Return>(
useEnhancedEffect(() => {
ref.current = fn;
});
return React.useCallback(
(...args: Args) =>
// @ts-expect-error hide `this`
// tslint:disable-next-line:ban-comma-operator
(0, ref.current!)(...args),
[],
);
return React.useRef((...args: Args) =>
// @ts-expect-error hide `this`
// tslint:disable-next-line:ban-comma-operator
(0, ref.current!)(...args),
).current;
}

export default useEventCallback;

0 comments on commit fdfaf64

Please sign in to comment.