Typescript Box conflicts with Material UI #1752
Replies: 19 comments 11 replies
-
We're experiencing the same issue. There's some discussion here: https://stackoverflow.com/questions/68692230/ts-expression-produces-a-union-type-that-is-too-complex-to-represent-with-materi As a temporary workaround we are using |
Beta Was this translation helpful? Give feedback.
-
We have the same issue also with the https://github.com/chakra-ui/chakra-ui |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
I think I am seeing this issue as well. |
Beta Was this translation helpful? Give feedback.
-
I'm currently seeing this issues as well and the whole I managed to replicate the Here's what I ended up with: import { Box as MuiBox, BoxProps, Theme } from "@mui/material";
import { SystemProps } from "@mui/system";
export interface CustomBoxProps extends SystemProps<Theme> {
sx?: BoxProps["sx"];
children?: React.ReactNode;
id?: string;
}
export function Box(props: CustomBoxProps) {
return <MuiBox component="div" {...props} />;
}
export function Main(props: CustomBoxProps) {
return <MuiBox component="main" {...props} />;
} I didn't spend any real time on replicating the rest of normal HTML props like |
Beta Was this translation helpful? Give feedback.
-
Why was the issue converted to a discussion? It's clearly a typescript definition error within react-three-fiber (MUI and Chakra UI are both affected, but do not affect each other) which needs to be fixed. According to some internet searches it affects quite a lot of people as well (everyone who is using react-fiber with MUI or Chakra UI). The proposed workaround works, but is not suitable since it needs unnecessary rewrites in hundreds of places. |
Beta Was this translation helpful? Give feedback.
-
The work-around with interface SomeViewComponentProps extends BoxProps { /* ... */ }
const SomeViewComponent = ({ /* ... ,*/ ...props}) => (
<Box {...props}>
{/* ... */}
</Box>
) Based on the hint in this post in combination with a hint in the above discussion, I've used patch-package to replace the cavalier global extension of declare global {
namespace JSX {
interface IntrinsicElements extends Pick<ThreeElements, 'ambientLight'/* | … */> {
}
}
} The patch looks like this and is easy to modify as needed: diff --git a/node_modules/@react-three/fiber/dist/declarations/src/three-types.d.ts b/node_modules/@react-three/fiber/dist/declarations/src/three-types.d.ts
index dadac00..31cff48 100644
--- a/node_modules/@react-three/fiber/dist/declarations/src/three-types.d.ts
+++ b/node_modules/@react-three/fiber/dist/declarations/src/three-types.d.ts
@@ -328,7 +328,7 @@ export interface ThreeElements {
}
declare global {
namespace JSX {
- interface IntrinsicElements extends ThreeElements {
+ interface IntrinsicElements extends Pick<ThreeElements, 'ambientLight'> {
}
}
} I would hope that it'd be possible to explicitly import the components instead of referencing them as natives, but AFAICS they don't actually exist. Neither have I found a way to generate them somehow. |
Beta Was this translation helpful? Give feedback.
-
What's the status on this issue? Edit: Are there any plans on fixing this issue? |
Beta Was this translation helpful? Give feedback.
-
Any progress/plans on fixing the issue? What's the priority? This is a major problem with project bases using mui or chakra. The quick fix is not a 100% solution. As if you perform unions within unions (example: mui sx prop), the issue will arise again eventually with enough sub-unions |
Beta Was this translation helpful? Give feedback.
-
Same issue all over our codebases. This is a massive issue for us and I am going to advise getting rid of the react-three-fiber implementation. |
Beta Was this translation helpful? Give feedback.
-
I'm encountering the same problem, What is the best solution please? |
Beta Was this translation helpful? Give feedback.
-
Also having this problem and it is shown in vs-code and browser disturbing us developing. I have a few genuine question on it.
|
Beta Was this translation helpful? Give feedback.
-
I patched Joy's Box component, but now the Menu component is having the same problem 😭 |
Beta Was this translation helpful? Give feedback.
-
Seemingly an overlapping issue but I'm seeing errors like The error is also appearing down stream from our code in MUI's Overridable component and is not restricted to 'form'. For example:
Edit: Seems like I'm incorrect on it being the exact same issue. My issue was cause by the change to 8.16.4 -> 8.16.5 #3270 |
Beta Was this translation helpful? Give feedback.
-
is there any update on this? It's really problematic, it's messing up the entire codebase. |
Beta Was this translation helpful? Give feedback.
-
Is there any update on this? The problem isn't only that it might enforce putting a |
Beta Was this translation helpful? Give feedback.
-
This really drives me mad. Please I beg of you please do something... 😫😭🥺 |
Beta Was this translation helpful? Give feedback.
-
@abernier @CodyJasonBennett @drcmda |
Beta Was this translation helpful? Give feedback.
-
This has to be a joke, how is this still an ongoing issue? |
Beta Was this translation helpful? Give feedback.
-
Hello,
When I install
@react-three/fiber
, all my components that use@mui/material/Box
start having the following error:Steps to reproduce:
npx create-react-app my-app --template typescript
package.json
npm install
Typescript v4.4.4
src
. I name itThreeRenderer.tsx
:App.tsx
and add aBox
component from@mui/material
.Beta Was this translation helpful? Give feedback.
All reactions