Skip to content

Commit

Permalink
[joy-ui] Fix issues reported by the React Compiler (#42671)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuujj committed Jun 20, 2024
1 parent da4546d commit 6c87fe3
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/mui-joy/src/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ const Checkbox = React.forwardRef(function Checkbox(inProps, ref) {

if (process.env.NODE_ENV !== 'production') {
const registerEffect = formControl?.registerEffect;
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
if (registerEffect) {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/FormControl/FormControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const FormControl = React.forwardRef(function FormControl(inProps, ref) {

let registerEffect: undefined | (() => () => void);
if (process.env.NODE_ENV !== 'production') {
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
const registeredInput = React.useRef(false);
registerEffect = () => {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ const Input = React.forwardRef(function Input(inProps, ref) {

if (process.env.NODE_ENV !== 'production') {
const registerEffect = formControl?.registerEffect;
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
if (registerEffect) {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ const Radio = React.forwardRef(function Radio(inProps, ref) {

if (process.env.NODE_ENV !== 'production') {
const registerEffect = formControl?.registerEffect;
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
if (registerEffect) {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/RadioGroup/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const RadioGroup = React.forwardRef(function RadioGroup(inProps, ref) {

if (process.env.NODE_ENV !== 'production') {
const registerEffect = formControl?.registerEffect;
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
if (registerEffect) {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ const Select = React.forwardRef(function Select<OptionValue extends {}, Multiple

if (process.env.NODE_ENV !== 'production') {
const registerEffect = formControl?.registerEffect;
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
if (registerEffect) {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ const Switch = React.forwardRef(function Switch(inProps, ref) {

if (process.env.NODE_ENV !== 'production') {
const registerEffect = formControl?.registerEffect;
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
if (registerEffect) {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Textarea/Textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ const Textarea = React.forwardRef(function Textarea(inProps, ref) {

if (process.env.NODE_ENV !== 'production') {
const registerEffect = formControl?.registerEffect;
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useEffect(() => {
if (registerEffect) {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ const Tooltip = React.forwardRef(function Tooltip(inProps, ref) {
const prevUserSelect: React.MutableRefObject<string | undefined> = React.useRef();
const stopTouchInteraction = useEventCallback(() => {
if (prevUserSelect.current !== undefined) {
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- WebkitUserSelect is required outside the component
(document.body.style as unknown as { WebkitUserSelect?: string }).WebkitUserSelect =
prevUserSelect.current;
prevUserSelect.current = undefined;
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/styles/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const useTheme = (): Theme => {
const theme = useSystemTheme(defaultTheme);

if (process.env.NODE_ENV !== 'production') {
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- process.env never changes
// eslint-disable-next-line react-hooks/rules-of-hooks
React.useDebugValue(theme);
}
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/styles/extendTheme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ describe('extendTheme', () => {

function Test() {
const theme = useTheme();
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- styles is required outside the component
styles = theme.unstable_sx({ bgcolor: 'primary.500' });
return null;
}
Expand Down

0 comments on commit 6c87fe3

Please sign in to comment.