So I use Chakra in my Nextjs 13 project, I have this code:
const Home = () => {
const color = useColorModeValue("telegram.500", "telegram.400");
return <div>something here</div>
}
I get this error: Error: (0 , _chakra_ui_react__WEBPACK_IMPORTED_MODULE_2__.useColorModeValue) is not a function
Here is some info:
"@chakra-ui/react": "^2.8.2",
"@chakra-ui/react": "^2.8.2",
2
Answers
This happens when you have imported it as default.
You should import as:
not
Per this GH Discussion, the solution may be as simple as adding
"use client"
at top of your file.I can confirm that worked for me, although "use client" has its own complications, such as incompatibility with Next directives like
Metadata
… YMMV whether it’s a permanent solution, but at least it’s an explanation.