Skip to content

Commit

Permalink
[docs-infra] Fix React Compiler ESLint issues in website components (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongarciah committed Jul 3, 2024
1 parent 91aee6e commit f0c14cf
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ module.exports = {
rules: {
'import/no-default-export': 'error',
'import/prefer-default-export': 'off',
...(ENABLE_REACT_COMPILER_PLUGIN ? { 'react-compiler/react-compiler': 'off' } : {}),
'react-compiler/react-compiler': 'off',
},
},
{
Expand Down
3 changes: 2 additions & 1 deletion docs/src/components/banner/AppFrameBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default function AppFrameBanner() {
return null;
}

// eslint-disable-next-line react-hooks/rules-of-hooks
// 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 -- FEATURE_TOGGLE never changes
const pageContext = React.useContext(PageContext);
const productName = convertProductIdToName(pageContext) || 'MUI';
const message = `Influence ${productName}'s 2024 roadmap! Participate in the latest Developer Survey`;
Expand Down
7 changes: 5 additions & 2 deletions docs/src/components/productMaterial/MaterialStyling.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ export const useResizeHandle = (
if (target.current && dragging && clientX) {
const objectRect = target.current.getBoundingClientRect();
const newWidth = clientX - objectRect.left + dragOffset;
target.current.style.width = `clamp(${minWidth}, ${Math.floor(newWidth)}px, ${maxWidth})`;
target.current.style.setProperty(
'width',
`clamp(${minWidth}, ${Math.floor(newWidth)}px, ${maxWidth})`,
);
}
}
function stopResize() {
Expand Down Expand Up @@ -148,7 +151,7 @@ export default function MaterialStyling() {
// 1px border-width
infoRef.current!.scroll({ top: scrollTo[index] * 18 + 16 - 1, behavior: 'smooth' });

objectRef.current!.style.width = '100%';
objectRef.current!.style.setProperty('width', '100%');
}, [index]);

return (
Expand Down
7 changes: 3 additions & 4 deletions docs/src/components/productX/XHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ export default function XHero() {
[],
);

let rowGroupingCounter = 0;
const rowGroupingCounterRef = React.useRef(0);
const isGroupExpandedByDefault = React.useCallback(() => {
// eslint-disable-next-line react-hooks/exhaustive-deps
rowGroupingCounter += 1;
return rowGroupingCounter === 3;
rowGroupingCounterRef.current += 1;
return rowGroupingCounterRef.current === 3;
}, []);

return (
Expand Down
8 changes: 7 additions & 1 deletion docs/src/components/productX/XPlans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ export default function XPlans2() {
<Grid size={{ xs: 12, md: 6 }}>
<Stack spacing={2} useFlexGap>
{content.map(({ icon, title, description, link }) => (
<InfoCard title={title} icon={icon} description={description} link={link} />
<InfoCard
key={title}
title={title}
icon={icon}
description={description}
link={link}
/>
))}
</Stack>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export function useApiPageOption(
const [option, setOption] = React.useState(getOption(storageKey, defaultValue));

useEnhancedEffect(() => {
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- useEnhancedEffect uses useEffect under the hood
neverHydrated = false;
const newOption = getOption(storageKey, defaultValue);
setOption(newOption);
Expand Down
1 change: 1 addition & 0 deletions docs/src/modules/components/AppNavDrawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ function PersistScroll(props) {
}

return () => {
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- useEnhancedEffect uses useEffect under the hood
savedScrollTop[slot] = scrollContainer.scrollTop;
};
}, [enabled, slot]);
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/DemoSandbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function FramedDemo(props) {

const theme = useTheme();
React.useEffect(() => {
document.body.dir = theme.direction;
document.body.setAttribute('dir', theme.direction);
}, [document, theme.direction]);

const { jss, sheetsManager } = React.useMemo(() => {
Expand Down
1 change: 1 addition & 0 deletions docs/src/modules/components/DemoToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ export default function DemoToolbar(props) {
const devMenuItems = [];
if (process.env.DEPLOY_ENV === 'staging' || process.env.DEPLOY_ENV === 'pull-request') {
/* eslint-disable material-ui/no-hardcoded-labels -- staging only */
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- valid reason to disable rules of hooks
// eslint-disable-next-line react-hooks/rules-of-hooks -- process.env never changes
const router = useRouter();

Expand Down
3 changes: 2 additions & 1 deletion docs/src/modules/components/ReactRunner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default function ReactRunner(props: ReactRunnerProps) {
let scope = scopeProp;

if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line react-hooks/rules-of-hooks
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- valid reason to disable the rules of hooks
// eslint-disable-next-line react-hooks/rules-of-hooks -- process.env never changes
scope = React.useMemo(() => {
const handler = {
get() {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/ThemeContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ export function ThemeProvider(props) {
}, [calculatedMode]);

useEnhancedEffect(() => {
document.body.dir = direction;
document.body.setAttribute('dir', direction);
}, [direction]);

useEnhancedEffect(() => {
Expand Down

0 comments on commit f0c14cf

Please sign in to comment.