0.0.2 • Published 5 years ago

react-livecode v0.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

react-livecode

Experimental

Live code evaluating:

  • Evaluate every expressions your typed, no need to use console.log.
  • Inspect result side by side.
  • Support modules (using import).

screenshot

Install

npm install react-livecode

Usage

import LiveCode from 'react-livecode'
import chunk from 'lodash/chunk'

render(
  <LiveCode
    scope={{chunk}}
    code={`
      2 ** 3
      chunk(['a', 'b', 'c', 'd'], 2)
    `}
  />
)

LiveCode props

PropTypeDefaultDescription
scopeObject{}Scope variables
codestring''Code to evaluate
splitstring'horizontal'How to split editor and console, can be horizontal or vertical
autoFocusbooleanfalseAuto focus editor
modulesbooleantrueEnable using of modules

Code highlighting

Import Prism styles to your page:

import 'prismjs/themes/prism.css'

Or, load from external CDN:

<link
  rel="stylesheet"
  href="https://unpkg.com/prismjs@1.15.0/themes/prism.css"
/>