make-react-great-again

0.0.1 • Public • Published

make react/antd great again

NPM JavaScript Style Guide

Install

npm install --save make-react-great-again

本项目试图对 react 和 antd 进行再封装,期望能达到以下目标

  1. 使用 HOCreactclass组件进行装饰

  2. 装饰器分为两个:page & component, page 装饰器可以设置页面title,其他功能如下

  3. 引入style样式

  4. 设置form: true后,自动将组件用 antd from 包裹,可在 props 中拿到 form 的方法, 也可以在 HOC 中封装更多方法

    Form.create({ name: 'wrapped_form_component' })(WrappedComponent);
  5. 可以把组件初始时的请求从生命周期中转移到preload中,结果直接挂载到 props

  6. 如果用到redux,则设置connect,将 mapStateToProps mapDispatchToProps 挂载到 props

  7. 更多基于 antdUI 组件封装...

使用示例

@hoc({
  form: true,
  style: require('./style.scss'),
  // 页面初始化时预加载一些请求,结果挂载到props上
  preload: (props) => ({
    preloadData: getNumber(props),
  }),
  connect: {},
})
class Demo extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    const { preloadData } = this.props;
    return (
      <div>
        <input type="text" className="text" />
        <div>{preloadData}</div>
      </div>
    );
  }
}

License

MIT © yangdepp © yx675258207

Dependencies (0)

    Dev Dependencies (27)

    Package Sidebar

    Install

    npm i make-react-great-again

    Weekly Downloads

    1

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    12.7 kB

    Total Files

    6

    Last publish

    Collaborators

    • yangdepp