Skip to content
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

[core] Improve React 19 support #16048

Merged
merged 30 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fb6cdef
[core] Improve React 19 support (#15769)
renovate[bot] Dec 30, 2024
38567b3
update lock
LukasTy Dec 31, 2024
5d2522d
Remove redundant `@types/react-test-render` dep
LukasTy Dec 31, 2024
948c271
Bump `@mui/internal-test-utils` and `@testing-library/react`
LukasTy Dec 31, 2024
0f271f8
Bump `sinon`
LukasTy Dec 31, 2024
cfc0a84
Bump `jsdom`
LukasTy Dec 31, 2024
d8af3cb
Run codemods
LukasTy Dec 31, 2024
2c71663
Fix new v7 problems
LukasTy Dec 31, 2024
9fc2d9f
prettier
LukasTy Dec 31, 2024
1e090e4
proptypes
LukasTy Dec 31, 2024
da21834
docs:typescript:formatted
LukasTy Dec 31, 2024
b036ac1
Bump mocha
LukasTy Dec 31, 2024
cc9626a
fix
LukasTy Dec 31, 2024
bed8db9
remove unwanted `| null` in ref
LukasTy Dec 31, 2024
9dbd4af
fix test
LukasTy Dec 31, 2024
f878fb5
Try without `act` over `exportState()` call
LukasTy Jan 1, 2025
2cce28b
Fix eslint issue
LukasTy Jan 1, 2025
89b7062
Try fixing a test
LukasTy Jan 1, 2025
1b2528d
Bump next
LukasTy Jan 1, 2025
df886f1
dedupe
LukasTy Jan 1, 2025
5647c47
Update `next-env.d.ts`
LukasTy Jan 1, 2025
5da939a
Bump `@mui/monorepo`
LukasTy Jan 1, 2025
7fac7d4
Bump `@mui/docs`
LukasTy Jan 1, 2025
d155a48
change chart line demo to be same as v8
JCQuintas Jan 1, 2025
0d13454
remove translation rule in docs/**
JCQuintas Jan 1, 2025
182adad
fix eslint
JCQuintas Jan 1, 2025
9c7b9bc
Revert "fix eslint"
JCQuintas Jan 1, 2025
650ef96
ignore error
JCQuintas Jan 1, 2025
4985964
Revert "remove translation rule in docs/**"
JCQuintas Jan 1, 2025
cad51b6
add inline rules
JCQuintas Jan 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/charts/tooltip/ItemTooltipFixedY.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function ItemTooltipFixedY() {
const svgRef = useSvgRef(); // Get the ref of the <svg/> component.
const drawingArea = useDrawingArea(); // Get the dimensions of the chart inside the <svg/>.

if (!tooltipData || !mousePosition) {
if (!tooltipData || !mousePosition || !svgRef.current) {
// No data to display
return null;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/charts/tooltip/ItemTooltipFixedY.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function ItemTooltipFixedY() {
const svgRef = useSvgRef(); // Get the ref of the <svg/> component.
const drawingArea = useDrawingArea(); // Get the dimensions of the chart inside the <svg/>.

if (!tooltipData || !mousePosition) {
if (!tooltipData || !mousePosition || !svgRef.current) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unique to v7.

// No data to display
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion docs/data/charts/tooltip/ItemTooltipTopElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export function ItemTooltipTopElement() {
if (
tooltipData.identifier.type !== 'bar' ||
tooltipData.identifier.dataIndex === undefined ||
tooltipData.value === null
tooltipData.value === null ||
svgRef.current === null
) {
// This demo is only about bar charts
return null;
Expand Down
3 changes: 2 additions & 1 deletion docs/data/charts/tooltip/ItemTooltipTopElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export function ItemTooltipTopElement() {
if (
tooltipData.identifier.type !== 'bar' ||
tooltipData.identifier.dataIndex === undefined ||
tooltipData.value === null
tooltipData.value === null ||
svgRef.current === null
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unique to v7.

) {
// This demo is only about bar charts
return null;
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
Loading
Loading