npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@codingame/monaco-editor-react

v9.0.0

Published

Monaco Editor React component

Downloads

475

Readme

@codingame/monaco-editor-react · monthly downloads npm version PRs welcome

Synopsis

This library uses https://github.com/CodinGame/monaco-editor-wrapper

Please refer to this documentation

Installation

npm install @codingame/monaco-editor-react 

Usage

Simple usage

Here is an example of a simple integration of monaco editor with a React project. You just need to import and render the Editor component:

import React from "react";
import ReactDOM from "react-dom";

import Editor from "@codingame/monaco-editor-react";

function App() {
  const [value, setValue] = useState('// some comment');
  return (
   <Editor
     height="auto"
     programmingLanguage="javascript"
     value={value}
     onChange={setValue}
   />
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Models management

When you render the MonacoEditor component, there is 2 modes for the model management:

  • if the model already exists, it will be reused and not disposed at the end
  • if the model doesn't exist, it will be created and disposed at the end

This way, the editor is plug-and-play for simple use cases but it allows you to create your models before, use them in the editor and dispose them when you don't need them anymore

Differences with monaco-react

  • This library outputs some dynamic import and rely on webpack to handle them
  • The model management is different, either you manage your models by hands or let the editor create and destroy them
  • no onValidate: can be done directly with monaco.editor.onDidChangeMarkers
  • no theme prop: the theme can be changed using monaco.editor.setTheme
  • To get the editor instance, use ref instead of handleEditorDidMount
  • There is no useMonaco, you can just use the exported monaco: import { monaco }, Editor from "@codingame/monaco-editor-react";