2.0.1 • Published 2 years ago

live-reacto v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

⚡️ Live Reacto

A Simple and flexible playground for live editing React code

React live component React live component React live component

Demo

Installation

$ npm install live-reacto
# or via yarn 
$ yarn add live-reacto

Usage

import { LiveProvider, LiveEditor, LivePreview } from 'live-reacto';

// import your favorite prismjs theme
import "prismjs/themes/prism-dark.css";

const codeTest = `function App() {
  const [count, setCount] = React.useState(0);
  const onCount = () => setCount(count + 1);
  return <div>{count} <button onClick={onCount}>Click me</button></div>
}

render(<App />)`;

// External component
const Hello = () => <h1>Hello world</h1>

<LiveProvider
  language="jsx" 
  code={codeTest}
  readOnly={false}
  onlyHighlight={false}
  bindings={{ Hello }} //-> bind component
>
  <LiveEditor onChange={setCode} />
  <LivePreview onTransform={setTransform} />
</LiveProvider>

Props

  • LiveProvider
PropTypeDescription
languagestringLanguage to be hightlighted (default: jsx)
codestringSome React code
bindingsObjectAdd an external component or library.
onlyHighlightBooleanDisable LivePreview: works as Syntax highlighter.
readOnlyBooleanDisable editing on the LiveEditor (Default: false).
  • LiveEditor
PropTypeDescription
onChangemethodreturns live coding
styleObjectset css style for editor
  • LivePreview
PropTypeDescription
onTransformmethodreturns the code transpiled by Babel

Peer dependencies

  • prismjs
  • react
  • react-dom
  • react-error-boundary
  • react-simple-code-editor
  • @babel/standalone

Notes

License

MIT

2.0.1

2 years ago

2.0.0

2 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago