You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mkarajohn
changed the title
[PageContainer] slotProps is not inferring the actual toolbar component's props
[PageContainer] slotProps is not inferring the actual toolbar component's props type
Dec 5, 2024
Instead of passing the intended props to the custom component via slotProps, you can pass it to the custom component itself and wrap the custom component definition in a useCallback, which you can pass to the slot instead of the component function.
Thanks; yeah, that will do for now, but i would consider this approach a workaround, I think the expected behaviour would be for the props to be inferred properly.
Steps to reproduce
toolbar
inPageContainer
, e.g.function PageActions({ status }: { status: string }) { ... }
slots
andslotProps
onPageContainer
:... slots={{ toolbar: PageActions }} slotProps={{ toolbar: { status: 'something' } }} ...
Current behavior
Typescript throws the following error over
slotProps
Expected behavior
The props type of
PageActions
component should be inferred and not throw when I pass the expected props toslotProps
Context
No response
Your environment
npx @mui/envinfo
Search keywords: PageContainer, slotprops, infer, toolbar
The text was updated successfully, but these errors were encountered: