-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Fix issues reported by react compiler in docs folder #42881
Conversation
Netlify deploy previewhttps://deploy-preview-42881--material-ui.netlify.app/ Bundle size report |
@@ -2,8 +2,8 @@ import * as React from 'react'; | |||
import { useRouter } from 'next/router'; | |||
import clipboardCopy from 'clipboard-copy'; | |||
|
|||
const CodeBlockContext = React.createContext<React.MutableRefObject<HTMLDivElement | null>>({ | |||
current: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when ref
is defined as null, react treats ref as unmutable. hence changed null to undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this documented somewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, using React.useRef<number | null>(null)
makes the ref mutable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay my bad, i misunderstood.
as of now, react-compiler throws error when modifying ref inside event handler. same issue was reported here facebook/react#29106. looks like it is treated as bug (facebook/react#29106 (comment)) and fixed here facebook/react#29591.
once fix gets published and we update eslint-plugin-react-complier
i'm expecting below error to go away. hence reverted all changes done in this file.
Error reported by current version of react-compiler:
@@ -81,6 +81,16 @@ export function useSetUserLanguage() { | |||
|
|||
const warnedOnce: Record<string, boolean> = {}; | |||
|
|||
const warn = (userLanguage: string, key: string, ignoreWarning: boolean) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function for top-level declarations
const warn = (userLanguage: string, key: string, ignoreWarning: boolean) => { | |
function warn(userLanguage: string, key: string, ignoreWarning: boolean) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should migrate to use the warnOnce
helper in the future mui/mui-x#13911. We can't yet, but eventually. I have left a TODO message in the code.
part of #42564