Skip to content

make-react-great-again/make-antd-great-again

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

make react/antd 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>
    );
  }
}

v_0.1

  1. 重写webpack配置,丰富功能。
  2. cssHotModuleReplacement未生效,原因不明😳

About

make react/antd great again🤣

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published