From 2dd576777e490f59e90338976bf58a67bab57399 Mon Sep 17 00:00:00 2001 From: Albin Arvidsson Date: Thu, 28 Nov 2024 12:31:50 +0100 Subject: [PATCH 1/2] Switch back to useCallback to avoid ESLint error Co-authored-by: wilhelmlofsten <107505740+wilhelmlofsten@users.noreply.github.com> --- .../mui-utils/src/useEventCallback/useEventCallback.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/mui-utils/src/useEventCallback/useEventCallback.ts b/packages/mui-utils/src/useEventCallback/useEventCallback.ts index 6b7bdb00e6ec3e..68823230770988 100644 --- a/packages/mui-utils/src/useEventCallback/useEventCallback.ts +++ b/packages/mui-utils/src/useEventCallback/useEventCallback.ts @@ -19,10 +19,11 @@ function useEventCallback( useEnhancedEffect(() => { ref.current = fn; }); - return React.useRef((...args: Args) => - // @ts-expect-error hide `this` - (0, ref.current!)(...args), - ).current; + return React.useCallback( + (...args: Args) => + ref.current(...args), + [], + ); } export default useEventCallback; From ac44245718ce541c22fc2b2448c313b25ab09bc7 Mon Sep 17 00:00:00 2001 From: Albin Arvidsson Date: Thu, 28 Nov 2024 12:53:31 +0100 Subject: [PATCH 2/2] Run prettier --- packages/mui-utils/src/useEventCallback/useEventCallback.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/mui-utils/src/useEventCallback/useEventCallback.ts b/packages/mui-utils/src/useEventCallback/useEventCallback.ts index 68823230770988..9760b7c200fcdd 100644 --- a/packages/mui-utils/src/useEventCallback/useEventCallback.ts +++ b/packages/mui-utils/src/useEventCallback/useEventCallback.ts @@ -19,11 +19,7 @@ function useEventCallback( useEnhancedEffect(() => { ref.current = fn; }); - return React.useCallback( - (...args: Args) => - ref.current(...args), - [], - ); + return React.useCallback((...args: Args) => ref.current(...args), []); } export default useEventCallback;