Skip to content

ambar/react-livecode

Repository files navigation

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

Prop Type Default Description
scope Object {} Scope variables
code string '' Code to evaluate
split string 'horizontal' How to split editor and console, can be horizontal or vertical
autoFocus boolean false Auto focus editor
modules boolean true Enable 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"
/>

About

Live Demo: https://ambar.li/react-livecode/

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •