-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Box from @mui/material/Box
and return from createBox
return different types
#35506
Comments
Nice, catch, there is a space for improvement here. We could add generics for the |
Great, thanks. Can you explain the root of the problem? I wouldn't expect the In the meantime, is it safe for us to do |
Hi, sorry to be a bother but can you let me know about whether it is safe for us to assert the type? Phrased differently, is this a type problem where the underlying code will accept the right props or is the object coming out of |
@subvertallchris sorry for the delay, it is a type, not a runtime problem. Doing a cast is the recommendation, until we merge #35532 which would fix the issue. As long as you use the right |
Btw, what's the motivation for creating a custom |
Perfect, thank you! Our theme extends the default with custom breakpoints,
a custom Box is needed to keep everything consistent.
…On Wed, Jan 4, 2023 at 6:25 AM Marija Najdova ***@***.***> wrote:
Btw, what's the motivation for creating a custom Box component?
—
Reply to this email directly, view it on GitHub
<#35506 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA7IJ5Y7ULGOXU4XY56SRFTWQVMYZANCNFSM6AAAAAATBRVUOM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
You shouldn't need a custom Box component for this but maybe there are more details that I am not aware of. The issue has been fixed, it will be part of the release next Monday. |
Odd, so what's the process to apply our theme's breakpoints to Box? It doesn't respect |
@mnajdova When you've got a moment, could you let me know if I could/should be doing something other than creating a custom Box if my goal is drawing breakpoints from our custom theme? |
Ah I see, the use-case there is if you want to process differently some values in the |
Duplicates
@mui/system
return different types. #29978. A fix was merged in December 2021. I'm not sure if this is a new issue or a regression.Latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/s/mystifying-fog-0xol3s?file=/src/App.tsx
Steps: You'll see the compiler error on line 10 when assigning the variable and then another on line 34 when we try to use BoxProps with an instance whose type has been inferred.
Current behavior 😯
There is a compiler error when you assign the output of
createBox
to a variable whose type istypeof Box
. It appears that thetypeof Box
coming fromcreateBox
and the one from@mui/material/Box
are different.Expected behavior 🤔
I expect that the
Box
returned bycreateBox
accepts the same props as theBox
imported from@mui/material/Box
so I can use them interchangeably.Context 🔦
I discovered that
Box
has a unique approach to custom themes, so I need to swap out my project's internal definition ofBox
with a custom one. After doing this, I'm seeing that spots where I spreadBoxProps
into components, like<CustomBox {...props}>
, get a compiler error. This is surprising becausecreateBox
has a return type oftypeof Box
, so I conclude that these are different boxes!Your environment 🌎
React 18 with MUI 5.11.0 in CodeSandbox and React 17 with MUI 5.8.3 locally. The browser appears to work correctly but I am concerned that these errors mean that the two Box versions will not behave consistently, so I don't know whether to push past the error by asserting type or wait for a fix.
Appreciate your help!
The text was updated successfully, but these errors were encountered: