All Projects → nihgwu → react-runner

nihgwu / react-runner

Licence: MIT license
Run your React code on the go

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to react-runner

ontwik-ui
ontwik-ui - A headless UI library
Stars: ✭ 52 (-83.12%)
Mutual labels:  playground
pg-deadlock-playground
Playground for verifying that queries cannot deadlock
Stars: ✭ 17 (-94.48%)
Mutual labels:  playground
janus-gateway-live
RTMP edge speed with janus-gateway
Stars: ✭ 38 (-87.66%)
Mutual labels:  live
bubble-hearts
(<3kb) 💖Bubble hearts animation.(Canvas 实现直播间点赞动画)
Stars: ✭ 44 (-85.71%)
Mutual labels:  live
midi-recorder
🎹 The easiest way to record MIDI. No install. Automatically records.
Stars: ✭ 38 (-87.66%)
Mutual labels:  live
node-reactive-postgres
Reactive queries for PostgreSQL
Stars: ✭ 28 (-90.91%)
Mutual labels:  live
bigscreen-player
Simplified media playback for bigscreen devices
Stars: ✭ 62 (-79.87%)
Mutual labels:  live
LiveHiddenCamera
Live Hidden Camera is a library which record live video and audio from Android device without displaying a preview.
Stars: ✭ 69 (-77.6%)
Mutual labels:  live
twitch-youtube-restream-chat-overlay
Access the YouTube Live chat and route it to your OBS or VMix Browser source.
Stars: ✭ 52 (-83.12%)
Mutual labels:  live
HeadFirstDesignPatternsSwift
An implementation of examples from "Head First Design Patterns", written in Swift.
Stars: ✭ 20 (-93.51%)
Mutual labels:  playground
ShareScreenServer
share android screen live on udp
Stars: ✭ 21 (-93.18%)
Mutual labels:  live
forum live-tangshan
django后台,移动app,功能有登录,支付、充值,礼物贴现申请,直播,论坛,好友,地区选择功能。
Stars: ✭ 38 (-87.66%)
Mutual labels:  live
vil
Vulkan Layer for Live Introspection & Debugging. Allows to view all vulkan state live inside your application.
Stars: ✭ 39 (-87.34%)
Mutual labels:  live
SFMediaStream
HTML5 media streamer library for playing music, video, playlist, or even live streaming microphone & camera with node server
Stars: ✭ 97 (-68.51%)
Mutual labels:  live
tiktok-download-userscript
Browser userscripts to download TikTok videos without watermark and get livestream URLs (to play in VLC).
Stars: ✭ 42 (-86.36%)
Mutual labels:  live
liveGestureDemo
仿映客双屏直播,OpenCV 竖屏检测,人脸贴纸
Stars: ✭ 26 (-91.56%)
Mutual labels:  live
stream-list-updater
Automation for updating an index of live George Floyd protest streams
Stars: ✭ 15 (-95.13%)
Mutual labels:  live
tvbus.android
tvbus.android is a live streaming android SDK based on P2P technology.
Stars: ✭ 72 (-76.62%)
Mutual labels:  live
minibed
It's a mini editable, customizable playground for web
Stars: ✭ 41 (-86.69%)
Mutual labels:  playground
ZLMediaKit
WebRTC/RTSP/RTMP/HTTP/HLS/HTTP-FLV/WebSocket-FLV/HTTP-TS/HTTP-fMP4/WebSocket-TS/WebSocket-fMP4/GB28181/SRT server and client framework based on C++11
Stars: ✭ 7,790 (+2429.22%)
Mutual labels:  live

React Runner

Run your React code on the go https://react-runner.vercel.app

Features

  • Inline element
  • Function component
  • Class component, with class fields support
  • Composing components with render or export default
  • Server Side Rendering
  • import statement
  • Multi files
  • Typescript

With React Runner, you can write your live code in the real world way, check out Hacker News in react-runner vs in real world, with the same code

You can even build your own async runner to support dynamic imports, try Play React

Install

# Yarn
yarn add react-runner

# NPM
npm install --save react-runner

Options

  • code string, required the code to be ran
  • scope object globals that could be used in code

Usage

import { Runner } from 'react-runner'

const element = <Runner code={code} scope={scope} onRendered={handleRendered} />

or use hook useRunner with cache support

import { useRunner } from 'react-runner'

const { element, error } = useRunner({ code, scope })

import statement and multi files

import { importCode } from 'react-runner'
import * as YourPkg from 'your-pkg'

const baseScope = {
  /* base globals */
}

const scope = {
  ...baseScope,
  // scope used by import statement
  import: {
    constants: { A: 'a' },
    'your-pkg': YourPkg,
    './local-file': importCode(localFileContent, baseScope),
  },
}

then in your live code you can import them

import { A } from 'constants'
import Foo, { Bar } from 'your-pkg'
import What, { Ever } from './local-file'

export default function Demo() {
  /* render */
}

Browser support

"browserslist": [
  "Chrome > 61",
  "Edge > 16",
  "Firefox > 60",
  "Safari > 10.1"
]

Resources

react-live-runner

react-runner is inspired by react-live heavily, I love it, but I love arrow functions for event handlers instead of bind them manually as well as other modern features, and I don't want to change my code to be compliant with restrictions, so I created this project, use Sucrase instead of Bublé to transpile the code.

If you are using react-live in your project and want a smooth transition, react-live-runner is there for you which provide the identical way to play with, and react-live-runner re-exports react-runner so you can use everything in react-runner by importing react-live-runner

import {
  LiveProvider,
  LiveEditor,
  LiveError,
  LivePreview,
} from 'react-live-runner'

...
<LiveProvider code={code} scope={scope}>
  <LiveEditor />
  <LivePreview />
  <LiveError />
</LiveProvider>
...

or hooks for better custom rendering

import { useLiveRunner, CodeEditor } from 'react-live-runner'

const { element, error, code, onChange } = useLiveRunner({
  initialCode,
  scope,
  transformCode,
})

...
<>
  <CodeEditor value={code} onChange={onChange}>
  <div>{element}</div>
  {error && <pre>{error}</pre>}
</>
...

or use react-runner directly

import { useState, useEffect } from 'react'
import { useRunner } from 'react-runner'

const [code, onChange] = useState(initialCode)
const { element, error } = useRunner({ code, scope })

useEffect(() => {
  onChange(initialCode)
}, [initialCode])

...
<>
  <textarea value={code} onChange={event => onChange(event.target.value)}>
  <div>{element}</div>
  {error && <pre>{error}</pre>}
</>
...

Check the real world usage here https://github.com/nihgwu/react-runner/blob/master/website/src/components/LiveRunner.tsx

License

MIT © Neo Nie

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].