-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[utils] support RSC in
isMuiElement
util (#38129)
- Loading branch information
Showing
1 changed file
with
9 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import * as React from 'react'; | ||
|
||
export default function isMuiElement(element: any, muiNames: readonly string[]): boolean { | ||
return React.isValidElement(element) && muiNames.indexOf((element.type as any).muiName) !== -1; | ||
return ( | ||
React.isValidElement(element) && | ||
muiNames.indexOf( | ||
// For server components `muiName` is avaialble in element.type._payload.value.muiName | ||
// relevant info - https://github.com/facebook/react/blob/2807d781a08db8e9873687fccc25c0f12b4fb3d4/packages/react/src/ReactLazy.js#L45 | ||
// eslint-disable-next-line no-underscore-dangle | ||
(element.type as any).muiName ?? (element.type as any)?._payload?.value?.muiName, | ||
) !== -1 | ||
); | ||
} |