Use @monaco-editor/react as a tsx editor
Has anyone figured out how todo this? I can only get any types for my jsx code and no syntax highlighting, which apparently is a general limitation.
Would highly appreciate any working code snippets or hint in the right direction.
Current code:
Thanks for reading!
5 Replies
I think the language for tsx should be set to typescriptreact
Nope that sadly doesn't work
@NotLuksus did you ever get this working? I'm trying to do the exact same thing.
Yeah I figured it out, basically what you need todo is fetch the react types and add them to your monaco editor by creating a new model in the react folder named index.d.ts and inside there save the @types/react index.d.ts
Would you be willing to share a sample or sandbox?
https://codesandbox.io/p/sandbox/monaco-example-9lc94l
Here is my attempt @NotLuksus, but
useState
does not have any types. I am already fetching the react types, and creating a new model at @@types/react/index.d.ts
.