Giter Site home page Giter Site logo

astralarya / react-console Goto Github PK

View Code? Open in Web Editor NEW
64.0 64.0 14.0 591 KB

Simple react console emulator

Home Page: https://astralarya.github.io/react-console/

License: GNU General Public License v3.0

JavaScript 18.91% CSS 0.08% TypeScript 76.77% HTML 1.33% SCSS 2.91%
react react-component readline terminal-emulators

react-console's People

Contributors

astralarya avatar mattmontgomery avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-console's Issues

First call to `.log()` can throw an exception?

I've modified the simple echo demo to include a button which calls .log() with some text when pressed.

The app will throw an exception if the very first thing I do is press the button. If, however, I first enter some text (including a CR) the button works correctly.

The exception is:

TypeError: Cannot read property 'message' of undefined
default_1.log
C:/Users/Admin/Documents/Work/console-bug/node_modules/react-console-component/lib/react-console.js:151
  148 |     messages[_i - 0] = arguments[_i];
  149 | }
  150 | var log = _this.state.log;
> 151 | log[_this.state.log.length - 1].message.push({ value: messages });
  152 | _this.setState({
  153 |     log: log,
  154 | }, _this.scrollIfBottom());

Source for App.js (using react-console-component 0.6.1):

import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import Console from 'react-console-component'
import 'react-console-component/main.css'

class App extends Component {
  child: { console?: Console } = {}
  echo = (text) => {
    this.child.console.log(text)
    this.child.console.return()
  }
  click = () => {
    this.echo("I was clicked!!!")
  }
  render() {
    return (
      <div className="App">
        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h1 className="App-title">Welcome to React</h1>
        </header>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
        <Console ref={ (r) => this.child.console = r}
                 handler={this.echo} autofocus={true} />
        <button onClick={this.click}>Click Me</button>
      </div>
    );
  }
}

export default App;

Cannot write a line without handler

I want to put some strings to the console without user input. But it crashes with

Uncaught TypeError: Cannot read property 'message' of undefined
    at default_1.log (react-console.js:151)

If I input something in the console, and then use a method to call

myconsole.log('blablabla');
myconsole.return();

without input handler to log a line to the console. It can show but the length seems some problem, it can show the blablabla and return a new line. But if I call this method once again, the new blablabla is append to the old one, ahead of the label

Paste

Any chance of being able to paste things in with Ctrl+V?

Where would be a good spot to start looking to integrate that?

Crtl+C to start a new line

Not really an issue but rather a feature request.

I really like this little console and almost the only thing I miss after the latest update is a way to clear my input:

In bash I can cancel the command I typed by pressing Crtl+C, a new line will be startet and the result will looks like this:

> asdf^C
> 

What do you think?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.