I have a newly created, near-empty next/react/fiber project, with a fiber Canvas. It throws the following warning every time I compile.
Warning: useLayoutEffect does nothing on the server, because its effect cannot be encoded into the server renderer's output format. This will lead to a mismatch between the initial, non-hydrated UI and the intended UI. To avoid this, useLayoutEffect should only be used in components that render exclusively on the client. See https://reactjs.org/link/uselayouteffect-ssr for common fixes.
at Canvas (C:\MyLocalFiles\Stratum\repos\cfgnext-updated\node_modules\@react-three\fiber\dist\react-three-fiber.cjs.dev.js:155:3)
Here is the smallest example that illustrates the problem, followed by package.json:
import { Canvas } from '@react-three/fiber'
export default function Home() {
return (
<div>
<Canvas>
</Canvas>
</div>
)
}
package.json
{
"name": "cfgnext-updated",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@react-three/drei": "^9.0.1",
"@react-three/fiber": "^8.0.6",
"babel-plugin-styled-components": "^2.0.6",
"next": "12.1.4",
"react": "18.0.0",
"react-dom": "18.0.0",
"styled-components": "^5.3.5"
},
"devDependencies": {
"eslint": "8.12.0",
"eslint-config-next": "12.1.4"
}
}
When I fill in the Canvas with other fiber components everything seems to work perfectly.
Could somebody tell me:
- Is this, in fact, a legitimate warning? If not
- Is there a way to eliminate it?
tia, Bill