# react-live **Repository Path**: mirrors_jquense/react-live ## Basic Information - **Project Name**: react-live - **Description**: A production-focused playground for live editing React components - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2026-04-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README

React Live

A production-focused playground for live editing React code

**React Live** brings you the ability to render React components and present the user with editable source code and live preview. It supports server-side rendering and comes in a tiny bundle, thanks to Bublé and a Prism.js-based editor. The library is structured modularly and lets you style its components as you wish and put them where you want. ## Usage Install it with `npm install react-live` and try out this piece of JSX: ```js import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live' ``` ## Demo [https://react-live.kitten.sh/](https://react-live.kitten.sh/) ## FAQ ### How does it work? It takes your code and transpiles it through Bublé, while the code is displayed using Prism.js. The transpiled code is then rendered in the preview component, which does a fake mount, if the code is a component. Easy peasy! ### What code can I use? The code can be one of the following things: - React elements, e.g. `Hello World!` - React pure functional components, e.g. `() => Hello World!` - React component classes If you enable the `noInline` prop on your `LiveProvider`, you’ll be able to write imperative code, and render one of the above things by calling `render`. ### How does the scope work? The `scope` prop on the `LiveProvider` accepts additional globals. By default it injects `React` only, which means that the user can use it in their code like this: ```js // ↓↓↓↓↓ class Example extends React.Component { render() { return Hello World! } } ``` But you can of course pass more things to this scope, that will be available as variables in the code. Here's an example using [styled components](https://github.com/styled-components/styled-components): ```js import styled from 'styled-components'; const headerProps = { text: 'I\'m styled!' }; const scope = {styled, headerProps}; const code = ` const Header = styled.div\` color: palevioletred; font-size: 18px; \` render(
{headerProps.text}
) ` ``` ## API ### <LiveProvider /> This component provides the `context` for all the other ones. It also transpiles the user’s code! It supports these props, while passing all others through to a `
`: |Name|PropType|Description| |---|---|---| |code|PropTypes.string|The code that should be rendered, apart from the user’s edits |scope|PropTypes.object|Accepts custom globals that the `code` can use |mountStylesheet|PropTypes.bool|Mounts the stylesheet for the prism editor (Default: `true`) |noInline|PropTypes.bool|Doesn’t evaluate and mount the inline code (Default: `false`) |transformCode|PropTypes.func|Accepts and returns the code to be transpiled, affording an opportunity to first transform it. Apart from these props it attaches the `.react-live` CSS class to its `div`. All subsequent components must be rendered inside a provider, since they communicate using one. By default this component will render a `