[docs] Fix issues reported by react compiler in docs folder#42881
[docs] Fix issues reported by react compiler in docs folder#42881aarongarciah merged 3 commits intomui:nextfrom
Conversation
Netlify deploy previewhttps://deploy-preview-42881--material-ui.netlify.app/ Bundle size report |
| import clipboardCopy from 'clipboard-copy'; | ||
|
|
||
| const CodeBlockContext = React.createContext<React.MutableRefObject<HTMLDivElement | null>>({ | ||
| current: null, |
There was a problem hiding this comment.
when ref is defined as null, react treats ref as unmutable. hence changed null to undefined
There was a problem hiding this comment.
Is this documented somewhere?
There was a problem hiding this comment.
In this case, using React.useRef<number | null>(null) makes the ref mutable.
There was a problem hiding this comment.
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:
|
|
||
| const warnedOnce: Record<string, boolean> = {}; | ||
|
|
||
| const warn = (userLanguage: string, key: string, ignoreWarning: boolean) => { |
There was a problem hiding this comment.
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.
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