Skip to content

Commit

Permalink
[utils] Fix issues reported by the React Compiler (#43051)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark <markliu2013@gmail.com>
Co-authored-by: Aarón García Hervás <aaron.garcia.hervas@gmail.com>
  • Loading branch information
markliu2013 and aarongarciah committed Jul 25, 2024
1 parent 75041b7 commit 263dbdd
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/mui-utils/src/useControlled/useControlled.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use client';
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes, dependency arrays are intentionally ignored
/* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */
import * as React from 'react';

Expand Down
1 change: 1 addition & 0 deletions packages/mui-utils/src/useForkRef/useForkRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function useForkRef<Instance>(
setRef(ref, instance);
});
};
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- intentionally ignoring that the dependency array must be an array literal
// eslint-disable-next-line react-hooks/exhaustive-deps
}, refs);
}
1 change: 1 addition & 0 deletions packages/mui-utils/src/useId/useId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default function useId(idOverride?: string): string | undefined {
const reactId = maybeReactUseId();
return idOverride ?? reactId;
}
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler
// eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
return useGlobalId(idOverride);
}
1 change: 1 addition & 0 deletions packages/mui-utils/src/useOnMount/useOnMount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const EMPTY = [] as unknown[];
* A React.useEffect equivalent that runs once, when the component is mounted.
*/
export default function useOnMount(fn: React.EffectCallback) {
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- no need to put `fn` in the dependency array
/* eslint-disable react-hooks/exhaustive-deps */
React.useEffect(fn, EMPTY);
/* eslint-enable react-hooks/exhaustive-deps */
Expand Down

0 comments on commit 263dbdd

Please sign in to comment.