Skip to content

Commit

Permalink
[core] Improve React 19 support (mui#15769)
Browse files Browse the repository at this point in the history
Signed-off-by: Armin Mehinovic <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jose Quintas <[email protected]>
Co-authored-by: Lukas <[email protected]>
Co-authored-by: flavien <[email protected]>
Co-authored-by: Armin Mehinovic <[email protected]>
Co-authored-by: Armin Mehinovic <[email protected]>
Co-authored-by: Bilal Shafi <[email protected]>
  • Loading branch information
7 people committed Dec 31, 2024
1 parent 6071413 commit fb6cdef
Show file tree
Hide file tree
Showing 131 changed files with 1,133 additions and 970 deletions.
62 changes: 57 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,27 @@ default-context: &default-context
context:
- org-global

test-react-18-context: &test-react-18-context
<<: *default-context
react-version: ^18.0.0
filters:
branches:
only:
- master
- /^v.*\.x$/
- next

commands:
install_js:
parameters:
browsers:
type: boolean
default: false
description: 'Set to true if you intend to any browser (for example with playwright).'
react-version:
type: string
default: << pipeline.parameters.react-version >>
description: The version of React to use.

steps:
- when:
Expand All @@ -81,14 +95,35 @@ commands:
# See https://stackoverflow.com/a/73411601
command: corepack enable --install-directory ~/bin

- when:
condition:
not:
equal: [stable, << parameters.react-version >>]
steps:
- run:
name: Change pnpm setting to not install peer dependencies
command: pnpm config set auto-install-peers false --location project

- run:
name: View install environment
command: |
node --version
pnpm --version
- run:
name: Install js dependencies
command: pnpm install
- when:
condition:
not:
equal: [stable, << parameters.react-version >>]
steps:
- run:
name: Install js dependencies without frozen lockfile
command: pnpm install --no-frozen-lockfile
- when:
condition:
equal: [stable, << parameters.react-version >>]
steps:
- run:
name: Install js dependencies
command: pnpm install

- run:
name: Resolve React version
Expand Down Expand Up @@ -127,7 +162,8 @@ jobs:
<<: *default-job
steps:
- checkout
- install_js
- install_js:
react-version: << parameters.react-version >>
- run:
name: Tests fake browser
command: pnpm test:coverage
Expand Down Expand Up @@ -226,6 +262,7 @@ jobs:
- checkout
- install_js:
browsers: true
react-version: << parameters.react-version >>
- run:
name: Tests real browsers
command: pnpm test:karma
Expand Down Expand Up @@ -257,6 +294,7 @@ jobs:
- checkout
- install_js:
browsers: true
react-version: << parameters.react-version >>
- run:
name: Run e2e tests
command: pnpm test:e2e
Expand All @@ -281,6 +319,7 @@ jobs:
- checkout
- install_js:
browsers: true
react-version: << parameters.react-version >>
- run:
name: Run visual regression tests
command: xvfb-run pnpm test:regressions
Expand All @@ -296,7 +335,6 @@ jobs:
name: Run danger on PRs
command: pnpm danger ci --fail-on-errors
workflows:
version: 2
pipeline:
when:
equal: [pipeline, << pipeline.parameters.workflow >>]
Expand Down Expand Up @@ -380,3 +418,17 @@ workflows:
- test_types:
<<: *default-context
name: test_types_additional
test-react-18:
jobs:
- test_unit:
<<: *test-react-18-context
name: test_unit_react_18
- test_browser:
<<: *test-react-18-context
name: test_browser_react_18
- test_regressions:
<<: *test-react-18-context
name: test_regressions_react_18
- test_e2e:
<<: *test-react-18-context
name: test_e2e_react_18
2 changes: 1 addition & 1 deletion docs/data/charts/components/ScaleDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const StyledText = styled('text')(({ theme }) => ({
shapeRendering: 'crispEdges',
}));

function ValueHighlight(props: { svgRef: React.RefObject<SVGSVGElement> }) {
function ValueHighlight(props: { svgRef: React.RefObject<SVGSVGElement | null> }) {
const { svgRef } = props;

// Get the drawing area bounding box
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/filtering/CustomMultiValueOperator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function InputNumberInterval(props) {
const rootProps = useGridRootProps();
const { item, applyValue, focusElementRef = null } = props;

const filterTimeout = React.useRef();
const filterTimeout = React.useRef(undefined);
const [filterValueState, setFilterValueState] = React.useState(item.value ?? '');
const [applying, setIsApplying] = React.useState(false);

Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/filtering/CustomMultiValueOperator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function InputNumberInterval(props: GridFilterInputValueProps) {
const rootProps = useGridRootProps();
const { item, applyValue, focusElementRef = null } = props;

const filterTimeout = React.useRef<any>();
const filterTimeout = React.useRef<ReturnType<typeof setTimeout>>(undefined);
const [filterValueState, setFilterValueState] = React.useState<[string, string]>(
item.value ?? '',
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/layout/MinMaxHeightGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function MinMaxHeightGrid() {
function ContainerMeasurements({
containerRef,
}: {
containerRef: React.RefObject<HTMLDivElement>;
containerRef: React.RefObject<HTMLDivElement | null>;
}) {
const [containerHeight, setContainerHeight] = React.useState(0);

Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/pagination/CursorPaginationGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function CursorPaginationGrid() {
}
};

const paginationMetaRef = React.useRef();
const paginationMetaRef = React.useRef(undefined);

// Memoize to avoid flickering when the `hasNextPage` is `undefined` during refetch
const paginationMeta = React.useMemo(() => {
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/pagination/CursorPaginationGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function CursorPaginationGrid() {
}
};

const paginationMetaRef = React.useRef<GridPaginationMeta>();
const paginationMetaRef = React.useRef<GridPaginationMeta>(undefined);

// Memoize to avoid flickering when the `hasNextPage` is `undefined` during refetch
const paginationMeta = React.useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ServerPaginationGridNoRowCount() {
pageInfo: { hasNextPage },
} = useQuery(paginationModel);

const paginationMetaRef = React.useRef();
const paginationMetaRef = React.useRef(undefined);

// Memoize to avoid flickering when the `hasNextPage` is `undefined` during refetch
const paginationMeta = React.useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function ServerPaginationGridNoRowCount() {
pageInfo: { hasNextPage },
} = useQuery(paginationModel);

const paginationMetaRef = React.useRef<GridPaginationMeta>();
const paginationMetaRef = React.useRef<GridPaginationMeta>(undefined);

// Memoize to avoid flickering when the `hasNextPage` is `undefined` during refetch
const paginationMeta = React.useMemo(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function TransitionComponent(props) {
});

return (
// @ts-expect-error
<animated.div style={style}>
<Collapse {...props} />
</animated.div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function TransitionComponent(props: TransitionProps) {
});

return (
// @ts-expect-error
<animated.div style={style}>
<Collapse {...props} />
</animated.div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function TransitionComponent(props) {
});

return (
// @ts-expect-error
<animated.div style={style}>
<Collapse {...props} />
</animated.div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function TransitionComponent(props: TransitionProps) {
});

return (
// @ts-expect-error
<animated.div style={style}>
<Collapse {...props} />
</animated.div>
Expand Down
24 changes: 12 additions & 12 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
"@emotion/server": "^11.11.0",
"@emotion/styled": "^11.13.0",
"@mui/docs": "6.1.6",
"@mui/icons-material": "^5.16.7",
"@mui/joy": "^5.0.0-beta.48",
"@mui/lab": "^5.0.0-alpha.173",
"@mui/material": "^5.16.7",
"@mui/material-nextjs": "^5.16.6",
"@mui/styles": "^5.16.7",
"@mui/system": "^5.16.7",
"@mui/utils": "^5.16.6",
"@mui/icons-material": "^5.16.13",
"@mui/joy": "^5.0.0-beta.51",
"@mui/lab": "^5.0.0-alpha.175",
"@mui/material": "^5.16.13",
"@mui/material-nextjs": "^5.16.13",
"@mui/styles": "^5.16.13",
"@mui/system": "^5.16.13",
"@mui/utils": "^5.16.13",
"@mui/x-charts": "workspace:*",
"@mui/x-charts-vendor": "workspace:*",
"@mui/x-data-grid": "workspace:*",
Expand Down Expand Up @@ -81,11 +81,11 @@
"postcss": "^8.4.47",
"prismjs": "^1.29.0",
"prop-types": "^15.8.1",
"react": "^18.3.1",
"react": "^19.0.0",
"react-docgen": "^5.4.3",
"react-dom": "^18.3.1",
"react-dom": "^19.0.0",
"react-hook-form": "^7.53.0",
"react-is": "^18.3.1",
"react-is": "^19.0.0",
"react-router": "^6.27.0",
"react-router-dom": "^6.27.0",
"react-runner": "^1.0.5",
Expand Down Expand Up @@ -113,7 +113,7 @@
"@types/moment-hijri": "^2.1.4",
"@types/moment-jalaali": "^0.7.9",
"@types/prop-types": "^15.7.13",
"@types/react-dom": "^18.3.1",
"@types/react-dom": "^19.0.2",
"@types/react-router-dom": "^5.3.3",
"@types/stylis": "^4.2.6",
"@types/webpack-bundle-analyzer": "^4.7.0",
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/PickersPlayground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const shortcutsItems: PickersShortcutsItem<DateRange<Dayjs>>[] = [
{ label: 'Reset', getValue: () => [null, null] },
];

function DisabledCheckboxTooltip({ children }: { children: React.ReactElement }) {
function DisabledCheckboxTooltip({ children }: { children: React.ReactElement<any> }) {
return (
<Tooltip title="At least one view has to be provided to the components">{children}</Tooltip>
);
Expand Down
6 changes: 3 additions & 3 deletions docs/src/modules/utils/useCustomizationPlayground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export type PickersSubcomponentType = {
[k: string]: {
examples: CustomizationItemsType;
slots: string[];
moreInformation?: React.ReactElement | string;
moreInformation?: React.ReactElement<any> | string;
};
};

export interface UseCustomizationPlaygroundProps {
examples: PickersSubcomponentType;
children?: React.ReactElement | React.ReactElement[];
children?: React.ReactElement<any> | React.ReactElement<any>[];
componentName: string;
}
export const customizationLabels: CustomizationLabelType = {
Expand Down Expand Up @@ -72,7 +72,7 @@ export type UseCustomizationPlaygroundReturnType = {
handleTokenChange: HandleTokenChangeType;
selectedTokens: StyleTokensType;
selectedExample?: CustomizationItemType | null;
moreInformation?: React.ReactElement | string | null;
moreInformation?: React.ReactElement<any> | string | null;
};

export function withStyles(
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@
"@emotion/cache": "^11.13.1",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/icons-material": "^5.16.7",
"@mui/icons-material": "^5.16.13",
"@mui/internal-babel-plugin-resolve-imports": "1.0.18",
"@mui/internal-markdown": "^1.0.19",
"@mui/internal-test-utils": "^1.0.17",
"@mui/material": "^5.16.7",
"@mui/material": "^5.16.13",
"@mui/monorepo": "github:mui/material-ui#7aa841466a01b745012e59e9d201ed50807a022e",
"@mui/utils": "^5.16.6",
"@mui/utils": "^5.16.13",
"@next/eslint-plugin-next": "14.2.15",
"@octokit/plugin-retry": "^7.1.2",
"@octokit/rest": "^21.0.2",
Expand All @@ -110,8 +110,8 @@
"@types/lodash": "^4.17.10",
"@types/mocha": "^10.0.9",
"@types/node": "^20.16.11",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react": "^19.0.2",
"@types/react-dom": "^19.0.2",
"@types/react-test-renderer": "^18.3.0",
"@types/requestidlecallback": "^0.3.7",
"@types/sinon": "^17.0.3",
Expand Down Expand Up @@ -179,8 +179,8 @@
"prettier": "^3.3.3",
"pretty-quick": "^4.0.0",
"process": "^0.11.10",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"remark": "^15.0.1",
"rimraf": "^6.0.1",
"serve": "^14.2.3",
Expand All @@ -198,7 +198,7 @@
"yargs": "^17.7.2"
},
"resolutions": {
"react-is": "^18.3.1",
"react-is": "^19.0.0",
"@types/node": "^20.16.11"
},
"packageManager": "[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions packages/x-charts-pro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
}
},
"devDependencies": {
"@mui/material": "^5.16.7",
"@mui/system": "^5.16.7",
"@mui/material": "^5.16.13",
"@mui/system": "^5.16.13",
"@react-spring/core": "^9.7.5",
"@react-spring/shared": "^9.7.5",
"@types/prop-types": "^15.7.13",
Expand Down
3 changes: 2 additions & 1 deletion packages/x-charts-pro/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"mocha",
"node"
],
"noImplicitAny": false
"noImplicitAny": false,
"skipLibCheck": true
},
"include": ["src/**/*", "../../test/utils/addChaiAssertions.ts"]
}
4 changes: 2 additions & 2 deletions packages/x-charts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
},
"devDependencies": {
"@mui/internal-test-utils": "^1.0.17",
"@mui/material": "^5.16.7",
"@mui/system": "^5.16.7",
"@mui/material": "^5.16.13",
"@mui/system": "^5.16.13",
"@react-spring/core": "^9.7.5",
"@react-spring/shared": "^9.7.5",
"@types/prop-types": "^15.7.13",
Expand Down
1 change: 1 addition & 0 deletions packages/x-charts/src/LineChart/AnimatedArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function AnimatedArea(props: AnimatedAreaProps) {
return (
<AppearingMask skipAnimation={skipAnimation} id={`${ownerState.id}-area-clip`}>
{transitionChange((style, interpolator) => (
// @ts-expect-error
<AreaElementPath {...other} ownerState={ownerState} d={style.value.to(interpolator)} />
))}
</AppearingMask>
Expand Down
Loading

0 comments on commit fb6cdef

Please sign in to comment.