Skip to content

Basic Usage

Jonathan Gertig edited this page Jul 11, 2017 · 4 revisions
import React, { Component } from 'react';
import Terminal from 'terminal-in-react';

class App extends Component {
  showMsg = () => 'Hello World';

  render() {
    return (
      <div>
        <Terminal
          commands={{
            'open-google': () => window.open("https://www.google.com/", "_blank"),
            showmsg: this.showMsg,
            popup: () => alert("Terminal in React")
          }}
          descriptions={{
            'open-google': 'opens google.com',
            showmsg: 'shows a message',
            popup: 'alert'
          }}
          msg="Terminal loaded."
        />
      </div>
    );
  }
}
Clone this wiki locally