Coder Social home page Coder Social logo

jarle's Introduction

J.A.R.L.E

Just Another React Live Editor

Jarle is a as light weight and feature rich React component editor with live preview.

Usage

import { Provider, Editor, Error, Preview } from 'jarle';

function LiveEditor() {
  return (
    <Provider code="<strong>Hello World!</strong>">
      <Editor />
      <Error />
      <Preview />
    </Provider>
  );
}

See https://jquense.github.io/jarle/ for docs.

Rendering Code

Jarle removes boilerplate code in your examples, by rendering the last expression in your code block. Define variables, components, whatever, as long as the last line is a JSX expression.

<Provider
  code={`
    function Example({ subject }) {
      return <div>Hello {subject}</div>
    }

    <Example subject="World"/>
  `}
/>

If you do need more control over what get's rendered, or need to render asynchronously, a render function is always in scope:

setTimeout(() => {
  render(<div>I'm late!</div>);
}, 1000);

Jarle also supports rendering your code as a component, helpful for illustrating hooks or render behavior with minimal extra code. When using renderAsComponent the code text is used as the body of React function component, so you can use state and other hooks.

<Provider
  renderAsComponent
  code={`
    const [secondsPast, setSeconds] = useState(0)

    useEffect(() => {
      let interval = setInterval(() => {
        setSeconds(prev => prev + 1)
      }, 1000)

      return () => clearInterval(interval)
    }, [])

    <div>Seconds past: {secondsPast}</div>
  `}
/>

Differences from React Live

  • No extra compiling. Jarle only packages a JSX transformer, making it lighter than alternatives.

  • Smart rendering

jarle's People

Contributors

jquense avatar mbrookes avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

swaggyp7

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.