I create a Next.js application that use Material-UI and @react-three/fiber library.
I recently pass Material-UI to V5 and a error is appear.
I search everything to remove it but I found nothing.
So I try to create a new project with Material-UI V5 and I install other dependency one by one. In the begin the error is not show but when I install @react-three/fiber
AND @react-three/drei
the error appear.
So I found that a Box
component is exported from @material-ui
and @react-three/drei
so I understand now the error.
Here is my package.json
:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@emotion/react": "^11.4.0",
"@emotion/styled": "^11.3.0",
"@material-ui/core": "^5.0.0-beta.2",
"@material-ui/styles": "^4.11.4",
"@react-three/fiber": "^7.0.6",
"next": "11.0.1",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@types/react": "17.0.16",
"eslint": "7.32.0",
"eslint-config-next": "11.0.1",
"typescript": "4.3.5"
}
}
My tsconfig.json
{
"compilerOptions": {
"baseUrl": "src",
"target": "es5",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
But I don't found how to fix it...
Someone have idee?
The stable version of MaterialUI fix this problem.
Use this package:
npm install @mui/material
Add the component
props to a div
to avoid TypeScript error.
<Box component="div">...</Box>