react-blessed
A React custom renderer for the blessed library.
This renderer should currently be considered as experimental, is subject to change and will only work with React's latest version (16.x.x, using Fiber).
Installation
You can install react-blessed
through npm:
Demo
For a quick demo of what you could achieve with such a renderer you can clone this repository and check some of the examples:
Usage
Rendering a basic application
Nodes & text nodes
Any of the blessed widgets can be rendered through react-blessed
by using a lowercased tag title.
Text nodes, on the other hand, will be rendered by applying the setContent
method with the given text on the parent node.
Refs
As with React's DOM renderer, react-blessed
lets you handle the original blessed nodes, if you ever need them, through refs.
Events
Any blessed node event can be caught through a on
-prefixed listener:
Classes
For convenience, react-blessed
lets you handle classes looking like what react-native proposes.
Just pass object or an array of objects as the class of your components likewise:
You can of course combine classes (note that the given array of classes will be compacted):
Using blessed forks
Because blessed is not actively maintained in quite a while, you might want to use one of it's forks. To do that, import createBlessedRenderer
function instead:
import React, {Component} from 'react';
import blessed from 'neo-blessed';
import {createBlessedRenderer} from 'react-blessed';
const render = createBlessedRenderer(blessed);