jsx2mp-runtime

0.4.25 • Public • Published

jsx2mp-runtime

Provide runtime support for rax style miniapp.

  • createComponent
    const __class_def__ = class {
      state = {
        name: 'Rax'
      };
    
      handleTap() {
        this.setState({
          name: 'MiniApp'
        });
      }
    };
    
    const config = createComponent(__class_def__, 'class');
    
    Component(config);
  • (state) useState(defaultValue, key)
    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)
    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);

/jsx2mp-runtime/

    Package Sidebar

    Install

    npm i jsx2mp-runtime

    Weekly Downloads

    185

    Version

    0.4.25

    License

    none

    Unpacked Size

    212 kB

    Total Files

    7

    Last publish

    Collaborators

    • zeroling
    • shiftj
    • likai757
    • solojiang
    • chriscindy
    • rax-publisher