I am facing an issue with a component in my Next JS website. When I attempt to convert it into a Client Component, the page fails to load in the browser and I encounter the following unhandled runtime exception:
SyntaxError: "undefined" is not valid JSON
.
Below is the code for the component which functions properly... however, if I remove the comment from the first line, everything goes haywire :-(
// 'use client';
export default function Test() {
return (
<div>
Testing 1, 2, 3!
</div>
)
}
I am using Next JS version 13.3.0 with experimental appDir feature enabled...
const nextConfig = {
experimental: {
appDir: true,
},
}
Not sure if this could be causing the issue. Although this specific component isn't in the app
directory - I moved it outside to a components
folder just in case (I found out that components in the app
folder are Server Components by default according to this article).
I'm currently stuck and unsure how to proceed. Any suggestions?