Skip to content

1.0.9

Latest
Compare
Choose a tag to compare
@i5ting i5ting released this 23 Dec 08:58
· 1 commit to main since this release
  • 让stateview返回fragment,这样开发者理解负担更低。同时可以适应游戏,小程序等兼容jsx的平台
  • 修改api写法,表述性更好 import { Stateview, Layer, setViewState, getStateview } from 'stateview';

最小示例,只有Logined和UnLogin二个状态。

import React from 'react';

import { Stateview, Layer, setViewState } from '~/index';

/**
 * 最简单的Demo:2个状态切换 
 */
export default () => {

  function unlogin() {
    setViewState('unlogin')
  }

  function logined() {
    setViewState('logined')
  }

  return (
    <Stateview default='unlogin'>
      <Layer state='logined'>
        <h1>Logined, <button onClick={unlogin}>go to UnLogin</button></h1>
      </Layer>
      <Layer state='unlogin'>
        <h1 >UnLogin, <button onClick={logined}>go to Logined</button></h1>
      </Layer>
    </Stateview>
  );
}