Skip to content

Instantly share code, notes, and snippets.

@y21
Created September 20, 2020 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save y21/049bf9cf9238339a6ae4984a4a15eb55 to your computer and use it in GitHub Desktop.
Save y21/049bf9cf9238339a6ae4984a4a15eb55 to your computer and use it in GitHub Desktop.
Embedded console
// https://github.com/y21/embedded-console
import EmbeddedConsole from './EmbeddedConsole';
import React from 'react';
export default class Console extends React.Component {
state = {};
componentDidMount() {
const element = document.getElementById('console');
if (!element) return console.error('Console element not found');
const ec = new EmbeddedConsole(element, {
height: '20%'
});
this.setState({ console: ec });
ec.log('Hello', 123);
// ...
}
render() {
return (
<div id="console"></div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment