Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jarle

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jarle

J.A.R.L.E Just Another React Live Editor

  • 3.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.4K
decreased by-38.49%
Maintainers
1
Weekly downloads
 
Created
Source

J.A.R.L.E

Just Another React Live Editor

JARLE is a as lightweight but feature-rich React component editor with live preview. JARLE uses sucrase for fast, minimal compilation of JSX and/or Typescript.

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>
  `}
/>

FAQs

Package last updated on 23 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc