# @race-ui/react-live

> react code live run

Latest version **0.0.9** (published 2021-09-30) · ISC license · 0 weekly downloads

## Install

```sh
npm install @race-ui/react-live
pnpm add @race-ui/react-live
yarn add @race-ui/react-live
bun add @race-ui/react-live
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.9 |
| Published | 2021-09-30 |
| First published | 2021-09-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 43.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zhangkun |
| Maintainers | zhang123456 |
| Keywords | react, react-live |

## Links

- npm: https://www.npmjs.com/package/@race-ui/react-live
- Repository: https://zzu1@bitbucket.org/zzu1/race-ui
- Homepage: https://bitbucket.org/zzu1/race-ui#readme
- Issues: https://bitbucket.org/zzu1/race-ui/issues
- npm.io page: https://npm.io/package/@race-ui/react-live

## Dependencies (5)

- [acorn](https://npm.io/package/acorn.md) ^8.5.0
- [escodegen](https://npm.io/package/escodegen.md) ^2.0.0
- [codemirror](https://npm.io/package/codemirror.md) ^5.62.3
- [@babel/standalone](https://npm.io/package/@babel/standalone.md) 7.7.1
- [react-codemirror2](https://npm.io/package/react-codemirror2.md) ^7.2.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.9 (latest) — 2021-09-30
- 0.0.8 — 2021-09-30
- 0.0.7 — 2021-09-30
- 0.0.6 — 2021-09-26
- 0.0.5 — 2021-09-26

## README

## @race-ui/react-live 说明文档

支持静态react代码，在线编辑与运行。 具体细节请查看 [examples](http://111.229.90.254:5057/react-live)

### 安装

```shell
npm install @race-ui/react-live --save

# 其他依赖安装
npm install @babel/standalone codemirror react-codemirror2 acorn escodegen --save
```

### 引入
```javascript
import ReactLive from '@race-ui/react-live';

import '@race-ui/react-live/assets/index.css';
```

### 写法
```jsx
const Code = `
  class Demo extends React.Component {
    constructor(props) {
      super(props)
      this.state = {
        value: 'Hello11331!'
      }
      this.handleChange = this.handleChange.bind(this)
    }
    // name
    handleChange(event) {
      this.setState({ value: event.target.value });
    }
    render() {
      var value = this.state.value;
      return (
        <div>
          <h1>Hello this is a Online Editor</h1>
          <input type="text" value={value} onChange={this.handleChange} />
          <p>{value}</p>
        </div>
      );
    }
  }
  ReactDOM.render(<Demo />, mountNode);
`;

ReactDOM.render(<ReactLive code={Code} />, mountNode);
```

### API
| 属性 | 默认值 | 参数类型 | 用法说明 |
| ------ | ------ | ------ | ------ |
| code | 必传 | string | 执行的react代码字符串 |
| className | - | string | 该组件样式 |
| defaultShowType | 'All' | ShowType（'All','Code','Preview'） | UI显示情况（'All': code与运行结果都显示， ‘Code’: 只显示code, 'Preview': 只显示渲染的UI） |
| scope | 'React', 'ReactDOM', 'mountNode' | ReactLiveScope | 执行code中的方法、组件等变量 |
| onChange | - | (currentCode: string) => void | 外部控制编辑代码 |

---
_Source: https://npm.io/package/@race-ui/react-live · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
