Skip to content

Commit b3298b8

Browse files
authored
[material-ui][docs] Add deprecations migration guide (#40767)
1 parent b813ffc commit b3298b8

File tree

7 files changed

+69
-6
lines changed

7 files changed

+69
-6
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Migrating from deprecated APIs
2+
3+
<p class="description">Learn how to migrate away from recently deprecated APIs before they become breaking changes.</p>
4+
5+
## Why you should migrate
6+
7+
Features become deprecated over time as maintainers make improvements to the APIs.
8+
Migrating to these improved APIs results in a better developer experience, so it's in your best interest to stay up to date.
9+
Deprecated APIs often become breaking changes in subsequent major versions, so the sooner you migrate, the smoother the next major update will be.
10+
11+
## Migrating
12+
13+
Material UI provides the `deprecations/all` codemod to help you stay up to date with minimal effort.
14+
15+
```bash
16+
npx @mui/codemod@latest deprecations/all <path>
17+
```
18+
19+
This command runs all the current [deprecations codemods](https://github.com/mui/material-ui/tree/master/packages/mui-codemod#deprecations), automatically migrating to the updated API.
20+
You can run this codemod as often as necessary to keep up with the latest changes.
21+
22+
:::info
23+
24+
If you need to manually migrate from a deprecated API, you can find examples below for all deprecations that have been added in Material UI v5.
25+
If you need to run a specific codemod, those are also linked below.
26+
27+
:::
28+
29+
## Accordion
30+
31+
### TransitionComponent
32+
33+
The Accordion's `TransitionComponent` was deprecated in favor of `slots.transition` ([Codemod](https://github.com/mui/material-ui/tree/master/packages/mui-codemod#accordion-props)):
34+
35+
```diff
36+
<Accordion
37+
- TransitionComponent={CustomTransition}
38+
+ slots={{ transition: CustomTransition }}
39+
/>
40+
```
41+
42+
### TransitionProps
43+
44+
The Accordion's `TransitionProps` was deprecated in favor of `slotProps.transition` ([Codemod](https://github.com/mui/material-ui/tree/master/packages/mui-codemod#accordion-props)):
45+
46+
```diff
47+
<Accordion
48+
- TransitionProps={{ unmountOnExit: true }}
49+
+ slotProps={{ transition: { unmountOnExit: true } }}
50+
/>
51+
```

docs/data/material/pages.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ const pages: MuiPage[] = [
266266
pathname: '/material-ui/migration',
267267
title: 'Migration',
268268
children: [
269+
{
270+
pathname: '/material-ui/migration/migrating-from-deprecated-apis',
271+
title: 'Migrating from deprecated APIs',
272+
},
269273
{
270274
pathname: '/material-ui/migration/migration-grid-v2',
271275
title: 'Migrating to Grid v2',

docs/pages/material-ui/api/accordion.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
"TransitionComponent": {
3333
"type": { "name": "elementType" },
3434
"deprecated": true,
35-
"deprecationInfo": "Use <code>slots.transition</code> instead. This prop will be removed in v7."
35+
"deprecationInfo": "Use <code>slots.transition</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
3636
},
3737
"TransitionProps": {
3838
"type": { "name": "object" },
3939
"deprecated": true,
40-
"deprecationInfo": "Use <code>slotProps.transition</code> instead. This prop will be removed in v7."
40+
"deprecationInfo": "Use <code>slotProps.transition</code> instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
4141
}
4242
},
4343
"name": "Accordion",
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import * as React from 'react';
2+
import MarkdownDocs from 'docs/src/modules/components/MarkdownDocs';
3+
import * as pageProps from 'docs/data/material/migration/migrating-from-deprecated-apis/migrating-from-deprecated-apis.md?@mui/markdown';
4+
5+
export default function Page() {
6+
return <MarkdownDocs {...pageProps} />;
7+
}

docs/translations/translations.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@
469469
"/material-ui/experimental-api/css-theme-variables/customization": "Customization",
470470
"/material-ui/experimental-api/css-theme-variables/migration": "Migrating to CSS variables",
471471
"/material-ui/migration": "Migration",
472+
"/material-ui/migration/migrating-from-deprecated-apis": "Migrating from deprecated APIs",
472473
"/material-ui/migration/migration-grid-v2": "Migrating to Grid v2",
473474
"/material-ui/migration/pickers-migration": "Migration from @material-ui/pickers",
474475
"Upgrade to v5": "Upgrade to v5",

packages/mui-material/src/Accordion/Accordion.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ export type AccordionTypeMap<
7979
/**
8080
* The component used for the transition.
8181
* [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
82-
* @deprecated Use `slots.transition` instead. This prop will be removed in v7.
82+
* @deprecated Use `slots.transition` instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
8383
*/
8484
TransitionComponent?: React.JSXElementConstructor<
8585
TransitionProps & { children?: React.ReactElement<any, any> }
8686
>;
8787
/**
8888
* Props applied to the transition element.
8989
* By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition/) component.
90-
* @deprecated Use `slotProps.transition` instead. This prop will be removed in v7.
90+
* @deprecated Use `slotProps.transition` instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
9191
*/
9292
TransitionProps?: TransitionProps;
9393
} & AccordionSlotsAndSlotProps;

packages/mui-material/src/Accordion/Accordion.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,13 @@ Accordion.propTypes /* remove-proptypes */ = {
293293
/**
294294
* The component used for the transition.
295295
* [Follow this guide](/material-ui/transitions/#transitioncomponent-prop) to learn more about the requirements for this component.
296-
* @deprecated Use `slots.transition` instead. This prop will be removed in v7.
296+
* @deprecated Use `slots.transition` instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
297297
*/
298298
TransitionComponent: PropTypes.elementType,
299299
/**
300300
* Props applied to the transition element.
301301
* By default, the element is based on this [`Transition`](http://reactcommunity.org/react-transition-group/transition/) component.
302-
* @deprecated Use `slotProps.transition` instead. This prop will be removed in v7.
302+
* @deprecated Use `slotProps.transition` instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
303303
*/
304304
TransitionProps: PropTypes.object,
305305
};

0 commit comments

Comments
 (0)