From da9eb421ce24929ca7b074f1d218cdb422ad2c5b Mon Sep 17 00:00:00 2001 From: sai6855 Date: Tue, 6 Feb 2024 11:53:22 +0530 Subject: [PATCH] Refactor useSlot function to dynamically determine elementType --- packages/mui-material/src/utils/useSlot.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mui-material/src/utils/useSlot.ts b/packages/mui-material/src/utils/useSlot.ts index 8709c030e95eab..2372f1093f3024 100644 --- a/packages/mui-material/src/utils/useSlot.ts +++ b/packages/mui-material/src/utils/useSlot.ts @@ -114,12 +114,12 @@ export default function useSlot< ...other } = externalForwardedProps; - const elementType = slots[name] || initialElementType; - // `slotProps[name]` can be a callback that receives the component's ownerState. // `resolvedComponentsProps` is always a plain object. const resolvedComponentsProps = resolveComponentProps(slotProps[name], ownerState); + const elementType = slots[name] || resolvedComponentsProps?.component || initialElementType; + const { props: { component: slotComponent, ...mergedProps }, internalRef,