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

[TreeView] Remove deprecated TreeView component #15093

Merged
merged 1 commit into from
Nov 7, 2024
Merged
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 @@ -63,6 +63,53 @@
Feel free to [open an issue](https://github.com/mui/mui-x/issues/new/choose) for support if you need help to proceed with your migration.
:::

### ✅ Use Simple Tree View instead of Tree View
Copy link
Member Author

Choose a reason for hiding this comment

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

Copied from last year's migration guide


The `<TreeView />` component has been renamed `<SimpleTreeView />` which has exactly the same API:

```diff
-import { TreeView } from '@mui/x-tree-view';
+import { SimpleTreeView } from '@mui/x-tree-view';

-import { TreeView } from '@mui/x-tree-view/TreeView';
+import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';

return (
- <TreeView>
+ <SimpleTreeView>
<TreeItem itemId="1" label="First item" />
- </TreeView>
+ </SimpleTreeView>
);
```

If you were using theme augmentation, you will also need to migrate it:

Check warning on line 86 in docs/data/migration/migration-tree-view-v7/migration-tree-view-v7.md

View workflow job for this annotation

GitHub Actions / runner / vale

[vale] reported by reviewdog 🐶 [Google.Will] Avoid using 'will'. Raw Output: {"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/data/migration/migration-tree-view-v7/migration-tree-view-v7.md", "range": {"start": {"line": 86, "column": 43}}}, "severity": "WARNING"}

```diff
const theme = createTheme({
components: {
- MuiTreeView: {
+ MuiSimpleTreeView: {
styleOverrides: {
root: {
opacity: 0.5,
},
},
},
},
});
```

If you were using the `treeViewClasses` object, you can replace it with the new `simpleTreeViewClasses` object:

```diff
import { treeViewClasses } from '@mui/x-tree-view/TreeView';
import { simpleTreeViewClasses } from '@mui/x-tree-view/SimpleTreeView';

-const rootClass = treeViewClasses.root;
+const rootClass = simpleTreeViewClasses.root;
```

## New API to customize the Tree Item

The `ContentComponent` or `ContentProps` props of the `TreeItem` component have been removed in favor of the new `slots`, `slotProps` props and of the `useTreeItem` hook.
Expand All @@ -83,7 +130,7 @@
</SimpleTreeView>
```

## Rename the `TreeItem2` (and related utils)
## Rename the `TreeItem2` (and related utils)

All the new Tree Item-related components and utils (introduced in the previous major to improve the DX of the Tree Item component) are becoming the default way of using the Tree Item and are therefore losing their `2` suffix:

Expand Down
4 changes: 0 additions & 4 deletions docs/data/treeViewApiPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,5 @@ const treeViewApiPages: MuiPage[] = [
pathname: '/x/api/tree-view/tree-item-icon',
title: 'TreeItemIcon',
},
{
pathname: '/x/api/tree-view/tree-view',
title: 'TreeView',
},
];
export default treeViewApiPages;
23 changes: 0 additions & 23 deletions docs/pages/x/api/tree-view/tree-view.js

This file was deleted.

129 changes: 0 additions & 129 deletions docs/pages/x/api/tree-view/tree-view.json

This file was deleted.

103 changes: 0 additions & 103 deletions docs/translations/api-docs/tree-view/tree-view/tree-view.json

This file was deleted.

23 changes: 22 additions & 1 deletion packages/x-codemod/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,29 @@ npx @mui/x-codemod@latest v8.0.0/tree-view/preset-safe <path|folder>

The list includes these transformers

- [`rename-tree-view-simple-tree-view`](#rename-tree-view-simple-tree-view)
- [`rename-tree-item-2`](#rename-tree-item-2)

#### `rename-tree-view-simple-tree-view`

Renames the Tree View component to Simple Tree View

```diff
-import { TreeView } from '@mui/x-tree-view';
+import { SimpleTreeView } from '@mui/x-tree-view';

-import { TreeView } from '@mui/x-tree-view/TreeView';
+import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';

return (
- <TreeView>
+ <SimpleTreeView>
<TreeItem itemId="1" label="First item" />
- </TreeView>
+ </SimpleTreeView>
);
```

#### `rename-tree-item-2`

Renames the `TreeItem2` component to `TreeItem` (same for any subcomponents or utils like `useTreeItem2` or `TreeItem2Icon`).
Expand Down Expand Up @@ -280,7 +301,7 @@ npx @mui/x-codemod@latest v7.0.0/tree-view/preset-safe <path|folder>

The list includes these transformers

- [`rename-tree-view-simple-tree-view`](#rename-tree-view-simple-tree-view)
- [`rename-tree-view-simple-tree-view`](#rename-tree-view-simple-tree-view-1)
- [`rename-use-tree-item`](#rename-use-tree-item)
- [`rename-expansion-props`](#rename-expansion-props)
- [`rename-selection-props`](#rename-selection-props)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// @ts-nocheck
import * as React from 'react';
import { TreeItem2 } from '@mui/x-tree-view/TreeItem2';
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView';
import { TreeView } from '@mui/x-tree-view/TreeView';

const className = treeViewClasses.root;

// prettier-ignore
<SimpleTreeView>
<TreeItem2 nodeId="1" label="Item 1" />
</SimpleTreeView>;
<TreeView>
<TreeItem2 itemId="1" label="Item 1" />
</TreeView>;
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ const className = treeViewClasses.root;

// prettier-ignore
<SimpleTreeView>
<TreeItem nodeId="1" label="Item 1" />
<TreeItem itemId="1" label="Item 1" />
</SimpleTreeView>;
Loading
Loading