Skip to content

Commit

Permalink
[utils] support RSC in isMuiElement util (#38129)
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 authored Sep 25, 2023
1 parent fcf2f60 commit bd446ad
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/mui-utils/src/isMuiElement.ts
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
);
}

0 comments on commit bd446ad

Please sign in to comment.