# jsx2mp-runtime

> Runtime for jsx2mp.

Latest version **0.4.25** (published 2021-11-01) · 0 weekly downloads

## Install

```sh
npm install jsx2mp-runtime
pnpm add jsx2mp-runtime
yarn add jsx2mp-runtime
bun add jsx2mp-runtime
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.25 |
| Published | 2021-11-01 |
| First published | 2019-05-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 207.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Rax Team |
| Maintainers | zeroling, likai757, solojiang, chriscindy, rax-publisher |

## Links

- npm: https://www.npmjs.com/package/jsx2mp-runtime
- npm.io page: https://npm.io/package/jsx2mp-runtime

## Recent versions

- 0.4.25 (latest) — 2021-11-01
- 0.4.26-2 (beta) — 2022-02-17
- 0.4.26-1 — 2022-02-10
- 0.4.26-0 — 2022-02-07
- 0.4.25-0 — 2021-10-21
- 0.4.24 — 2021-09-26
- 0.4.24-1 — 2021-09-17
- 0.4.24-0 — 2021-09-17
- 0.4.23 — 2021-08-24
- 0.4.33-2 — 2021-08-17
- 0.4.33-0 — 2021-08-11
- 0.4.23-1 — 2021-07-12
- 0.4.23-0 — 2021-07-12
- 0.4.22 — 2021-07-07
- 0.4.22-0 — 2021-07-02
- … 116 more at https://npm.io/package/jsx2mp-runtime/versions

## README

# jsx2mp-runtime

Provide runtime support for rax style miniapp.

- createComponent
   ```js
   const __class_def__ = class {
     state = {
       name: 'Rax'
     };
   
     handleTap() {
       this.setState({
         name: 'MiniApp'
       });
     }
   };
   
   const config = createComponent(__class_def__, 'class');

  Component(config);
  ```
- (state) useState(defaultValue, key)
  ```js
  const __fn_def__ = function Header(props) {
    const [name, setName] = useState('World', 'name');
    const [count, setCount] = useState(0, 'count');
  
    return {
      handleClick() {
        setName('Rax');
        setCount(count + 1);
      }
    }
  };
  
  const config = createComponent(__fn_def__, 'function');
  Component(config);
  ```
- (void) useEffect(callback)
  ```js
  const __fn_def__ = function Header(props) {
    const [name, setName] = useState('World', 'name');
    useEffect(() => {
      console.log('didMount');
  
      return function unmount() {
        console.log('unmount');
      };
    }, []);
  
    return {
      handleClick: () => {
        setName('Rax');
      },
    };
  };
  
  const config = createComponent(__fn_def__, 'function');
  Component(config);
  ```

---
_Source: https://npm.io/package/jsx2mp-runtime · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
