Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mytecor/live-example

React live code preview
https://github.com/mytecor/live-example

jsx preview react sucrase

Last synced: 11 days ago
JSON representation

React live code preview

Awesome Lists containing this project

README

        

# live-example
###### React live code preview

[In action (Playground)](https://mytecor.github.io/live-example)

#### Usage example
```js
import React from 'react'
import Compiler from 'live-example'
import CodeEditor from 'rmce'
import 'rmce/index.css'

function CustomButton({children}) {
return {children}
}

function Fallback({error}) {
return

{error.message}

}

let bindings = { CustomButton }

function MyFancyExample() {
let [code, setCode] = React.useState('TEST')

return







}

ReactDOM.render(, document.getElementById('root'))
```

##### Also you can use class components and raw jsx
```js
class extends React.Component {
render() {
return TEST
}
}
// or
TEST
```

#### Props
```ts
class Props {
// Current value of the code to compile
code: string = ''

// Bindings provided for sucrase
bindings: object = {}

// Fallback component
fallback: ComponentClass | FunctionComponent = () => null
}
```