drei icon indicating copy to clipboard operation
drei copied to clipboard

Using Box from MUI cause error

Open dspaethe opened this issue 3 years ago • 7 comments

After adding the component "drei" to my existing project, every occurrence of Box from Material UI (mui.com) produce this error: Expression produces a union type that is too complex to represent. TS2590

Adding this completely redundant property to every single Box in the whole project solve it somehow: component='div' https://stackoverflow.com/questions/68692230 But this workaround is very ugly.

Similar issue reported here: https://github.com/pmndrs/drei/issues/704#issuecomment-1050199077_

dspaethe avatar Mar 22 '22 13:03 dspaethe

Same thing here. This is not great for MUI users.

mracette avatar Apr 22 '22 14:04 mracette

Do you have an idea of what's causing this problem? From the stack overflow it looks like removing some random d files "solves it", but it's not clear to me why those specific files would be a problem.

I don't get why ts would fail to correctly guess the type of Box since both would be imported and not parts of global namespace overrides 🤔

@joshuaellis @CodyJasonBennett ideas?

gsimone avatar Apr 22 '22 14:04 gsimone

This pretty clearly sounds like a larger issue with TypeScript although I'd be interested in potential workarounds regarding the Box component.

CodyJasonBennett avatar Apr 22 '22 15:04 CodyJasonBennett

Some insight into why TS produces this error can be found here: https://github.com/microsoft/TypeScript/issues/33130

mracette avatar Apr 22 '22 16:04 mracette

I've seen this issue in projects that don't use drei. I was able to solve it by specifying the component prop of MUI Box components as div like this

<Box component="div" ... \>

reggie3 avatar May 07 '22 18:05 reggie3

Just for cross-referencing, I filed https://github.com/mui/material-ui/issues/34068 in the MUI repo with more of an explanation of what's going on.

Methuselah96 avatar Aug 24 '23 15:08 Methuselah96

I am using @react-three/drei, @react-three/fiber and mui packages.. It seem like each packages have their Box element.. it cause conflict on each other..

References: https://github.com/mui/material-ui/issues/34068 https://github.com/pmndrs/react-three-fiber/discussions/1752#discussioncomment-5602430

zigang93 avatar Sep 25 '23 02:09 zigang93