From eee1c241f27ee2f99e553ead33fd767ce6d8eead Mon Sep 17 00:00:00 2001 From: Flavien DELANGLE Date: Tue, 17 Sep 2024 10:03:00 +0200 Subject: [PATCH] [TreeView] Add `"use client"` directive to every public component and hook (#14579) --- packages/rsc-builder/buildRsc.ts | 10 ++++++++++ .../src/RichTreeViewPro/RichTreeViewPro.tsx | 1 + packages/x-tree-view/src/RichTreeView/RichTreeView.tsx | 1 + .../x-tree-view/src/SimpleTreeView/SimpleTreeView.tsx | 1 + packages/x-tree-view/src/TreeItem/TreeItem.tsx | 1 + packages/x-tree-view/src/TreeItem/useTreeItemState.ts | 1 + packages/x-tree-view/src/TreeItem2/TreeItem2.tsx | 1 + packages/x-tree-view/src/TreeView/TreeView.tsx | 1 + packages/x-tree-view/src/hooks/useTreeViewApiRef.tsx | 1 + 9 files changed, 18 insertions(+) diff --git a/packages/rsc-builder/buildRsc.ts b/packages/rsc-builder/buildRsc.ts index 2fb4e0b54549..f5bd1f4cc29d 100644 --- a/packages/rsc-builder/buildRsc.ts +++ b/packages/rsc-builder/buildRsc.ts @@ -14,6 +14,8 @@ type Project = { ignorePaths?: string[]; }; +// The data grid packages are not using this script. +// Instead, they are manually adding the "use client" directive in the entry point of each package. const PROJECTS: Project[] = [ { name: 'x-date-pickers', @@ -31,6 +33,14 @@ const PROJECTS: Project[] = [ name: 'x-charts-pro', rootPath: path.join(process.cwd(), 'packages/x-charts-pro'), }, + { + name: 'x-tree-view', + rootPath: path.join(process.cwd(), 'packages/x-tree-view'), + }, + { + name: 'x-tree-view-pro', + rootPath: path.join(process.cwd(), 'packages/x-tree-view-pro'), + }, ]; async function processFile( diff --git a/packages/x-tree-view-pro/src/RichTreeViewPro/RichTreeViewPro.tsx b/packages/x-tree-view-pro/src/RichTreeViewPro/RichTreeViewPro.tsx index 6259d7d4c427..0cb18fa82006 100644 --- a/packages/x-tree-view-pro/src/RichTreeViewPro/RichTreeViewPro.tsx +++ b/packages/x-tree-view-pro/src/RichTreeViewPro/RichTreeViewPro.tsx @@ -1,3 +1,4 @@ +'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; import composeClasses from '@mui/utils/composeClasses'; diff --git a/packages/x-tree-view/src/RichTreeView/RichTreeView.tsx b/packages/x-tree-view/src/RichTreeView/RichTreeView.tsx index ecc2ba95a2ff..755b5f821361 100644 --- a/packages/x-tree-view/src/RichTreeView/RichTreeView.tsx +++ b/packages/x-tree-view/src/RichTreeView/RichTreeView.tsx @@ -1,3 +1,4 @@ +'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; import composeClasses from '@mui/utils/composeClasses'; diff --git a/packages/x-tree-view/src/SimpleTreeView/SimpleTreeView.tsx b/packages/x-tree-view/src/SimpleTreeView/SimpleTreeView.tsx index 1556d2df9941..adfe2d35415b 100644 --- a/packages/x-tree-view/src/SimpleTreeView/SimpleTreeView.tsx +++ b/packages/x-tree-view/src/SimpleTreeView/SimpleTreeView.tsx @@ -1,3 +1,4 @@ +'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; import composeClasses from '@mui/utils/composeClasses'; diff --git a/packages/x-tree-view/src/TreeItem/TreeItem.tsx b/packages/x-tree-view/src/TreeItem/TreeItem.tsx index 6831bcee8055..3f27e6ccfae2 100644 --- a/packages/x-tree-view/src/TreeItem/TreeItem.tsx +++ b/packages/x-tree-view/src/TreeItem/TreeItem.tsx @@ -1,3 +1,4 @@ +'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; diff --git a/packages/x-tree-view/src/TreeItem/useTreeItemState.ts b/packages/x-tree-view/src/TreeItem/useTreeItemState.ts index a236983664ee..f28549c2603c 100644 --- a/packages/x-tree-view/src/TreeItem/useTreeItemState.ts +++ b/packages/x-tree-view/src/TreeItem/useTreeItemState.ts @@ -1,3 +1,4 @@ +'use client'; import * as React from 'react'; import { MuiCancellableEvent } from '../internals/models/MuiCancellableEvent'; import { useTreeViewContext } from '../internals/TreeViewProvider'; diff --git a/packages/x-tree-view/src/TreeItem2/TreeItem2.tsx b/packages/x-tree-view/src/TreeItem2/TreeItem2.tsx index 1b3676f173b3..86a398dee5d4 100644 --- a/packages/x-tree-view/src/TreeItem2/TreeItem2.tsx +++ b/packages/x-tree-view/src/TreeItem2/TreeItem2.tsx @@ -1,3 +1,4 @@ +'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; diff --git a/packages/x-tree-view/src/TreeView/TreeView.tsx b/packages/x-tree-view/src/TreeView/TreeView.tsx index ad40046fb705..73c38055ee9a 100644 --- a/packages/x-tree-view/src/TreeView/TreeView.tsx +++ b/packages/x-tree-view/src/TreeView/TreeView.tsx @@ -1,3 +1,4 @@ +'use client'; import * as React from 'react'; import PropTypes from 'prop-types'; import composeClasses from '@mui/utils/composeClasses'; diff --git a/packages/x-tree-view/src/hooks/useTreeViewApiRef.tsx b/packages/x-tree-view/src/hooks/useTreeViewApiRef.tsx index 6a62287d93a4..f36ed0c4eacd 100644 --- a/packages/x-tree-view/src/hooks/useTreeViewApiRef.tsx +++ b/packages/x-tree-view/src/hooks/useTreeViewApiRef.tsx @@ -1,3 +1,4 @@ +'use client'; import * as React from 'react'; import { TreeViewAnyPluginSignature, TreeViewPublicAPI } from '../internals/models'; import { RichTreeViewPluginSignatures } from '../RichTreeView/RichTreeView.plugins';