Monaco Editor for React - use the monaco-editor in any React application without needing to use webpack (or rollup/parcel/etc) configuration files / plugins
Describe the bug
In a clean Next.js project, when I npm install @monaco-editor/react and simply try to display an editor somewhere (which should be possible, as per the docs), I get an error
Error: useState only works in Client Components. Add the "use client" directive at the top of the file to use it.
Create fresh Next.js app (I used the CodeSandbo "Next.js (App Router)" template)
Install @monaco-editor/react
Display an <Editor /> somewhere
See above error
Optionally try to wrap the import in a dynamic(..., { ssr: false }), same result
Expected behavior
There should be no error, as per the docs linked above.
Desktop (please complete the following information):
OS: macOS
Browser Arc
Version 4.6.0
Additional context
I briefly checked the source code and found a 'use client' at the top of the corresponding TSX files. However, that 'use client' seems to get lost in the build process because it isn't present in the final index.mjs.
Describe the bug In a clean Next.js project, when I
npm install @monaco-editor/react
and simply try to display an editor somewhere (which should be possible, as per the docs), I get an errorTo Reproduce See this CodeSandbox
Steps to reproduce the behavior:
@monaco-editor/react
<Editor />
somewheredynamic(..., { ssr: false })
, same resultExpected behavior There should be no error, as per the docs linked above.
Desktop (please complete the following information):
Additional context I briefly checked the source code and found a 'use client' at the top of the corresponding TSX files. However, that 'use client' seems to get lost in the build process because it isn't present in the final index.mjs.