react-cli/App.js
2019-11-18 13:49:59 -05:00

34 lines
727 B
JavaScript

import React, { Component } from 'react'
import blessed from 'blessed'
import { render } from 'react-blessed'
import { Box } from './components'
const getDefaultState = () => ({ text: 'Hello, world!' })
// Rendering a simple centered box
class App extends Component {
constructor() {
super()
this.state = getDefaultState()
}
render() {
return <Box {...this.state} />
}
}
// Creating our screen
const screen = blessed.screen({
autoPadding: true,
smartCSR: true,
title: 'hello world',
})
// Adding a way to quit the program
screen.key(['escape', 'q', 'C-c'], () => {
//callback has access to ch, key
return process.exit(0)
})
// Rendering the React app using our screen
render(<App />, screen)