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

[material-ui][Badge] Deprecate components and componentsProps props #41360

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,33 @@ The Divider's `light` prop was deprecated, Use `sx={{ opacity : "0.6" }}` (or an
+ sx={{ opacity : "0.6" }}
/>
```

## Badge

Use the [codemod](https://github.com/mui/material-ui/tree/HEAD/packages/mui-codemod#badge-props) below to migrate the code as described in the following sections:

```bash
npx @mui/codemod@latest deprecations/badge-props <path>
```

### components

The Badge's `components` was deprecated in favor of `slots`:

```diff
<Badge
- components={{ Badge: CustomBadge }}
+ slots={{ badge: CustomBadge }}
/>
```

### componentsProps

The Badge's `componentsProps` was deprecated in favor of `slotProps`:

```diff
<Badge
- componentsProps={{ badge: { testid: 'test-id' } }}
+ slotProps={{ badge: { testid: 'test-id' } }}
/>
```
22 changes: 20 additions & 2 deletions docs/pages/material-ui/api/badge.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
"component": { "type": { "name": "elementType" } },
"components": {
"type": { "name": "shape", "description": "{ Badge?: elementType, Root?: elementType }" },
"default": "{}"
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slotProps</code> prop instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"componentsProps": {
"type": {
"name": "shape",
"description": "{ badge?: func<br>&#124;&nbsp;object, root?: func<br>&#124;&nbsp;object }"
},
"default": "{}"
"default": "{}",
"deprecated": true,
"deprecationInfo": "use the <code>slotProps</code> prop instead. This prop will be removed in v7. <a href=\"/material-ui/migration/migrating-from-deprecated-apis/\">How to migrate</a>."
},
"invisible": { "type": { "name": "bool" }, "default": "false" },
"max": { "type": { "name": "number" }, "default": "99" },
Expand Down Expand Up @@ -64,6 +68,20 @@
},
"name": "Badge",
"imports": ["import Badge from '@mui/material/Badge';", "import { Badge } from '@mui/material';"],
"slots": [
{
"name": "badge",
"description": "",
"default": "",
"class": null
},
{
"name": "root",
"description": "",
"default": "",
"class": null
}
],
"classes": [
{
"key": "anchorOriginBottomLeft",
Expand Down
12 changes: 8 additions & 4 deletions docs/translations/api-docs/badge/badge.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
"description": "The component used for the root node. Either a string to use a HTML element or a component."
},
"components": {
"description": "The components used for each slot inside.<br>This prop is an alias for the <code>slots</code> prop. It&#39;s recommended to use the <code>slots</code> prop instead."
"description": "The components used for each slot inside."
},
"componentsProps": {
"description": "The extra props for the slot components. You can override the existing props or add new ones.<br>This prop is an alias for the <code>slotProps</code> prop. It&#39;s recommended to use the <code>slotProps</code> prop instead, as <code>componentsProps</code> will be deprecated in the future."
"description": "The extra props for the slot components. You can override the existing props or add new ones."
},
"invisible": { "description": "If <code>true</code>, the badge is invisible." },
"max": { "description": "Max count to show." },
"overlap": { "description": "Wrapped shape the badge should overlap." },
"showZero": {
"description": "Controls whether the badge is hidden when <code>badgeContent</code> is zero."
},
"slotProps": { "description": "The props used for each slot inside the Badge." },
"slotProps": { "description": "The props used for each slot inside." },
"slots": {
"description": "The components used for each slot inside the Badge. Either a string to use a HTML element or a component."
"description": "The components used for each slot inside."
},
"sx": {
"description": "The system prop that allows defining system overrides as well as additional CSS styles."
Expand Down Expand Up @@ -153,5 +153,9 @@
"nodeName": "the badge <code>span</code> element",
"conditions": "<code>variant=\"standard\"</code>"
}
},
"slotDescriptions": {
"badge": "",
"root": ""
}
}
Loading