Home Reference Source Repository

Daifee-React-Component

Build Status

一套决定项目 UI 风格的 react component。

所有组件都是 stateless 组件,但为方便,某些组件提供 API 调用方式的静态方法。


[TOC]

使用

源码被构建成 UMD 模块发布到 NPM.

npm install -s daifee-react-component

依赖:

Dialog 为例:

// 组件形式
import {Dialog} from 'path';

class DialogPage extends React.Component {
  render() {
    return (
      <div>
        <Dialog
          show={true}
          title='Dialog'
          content='demo'
          buttons={[{text: '确定', onClick: (e) => {}}]} />
      </div>
    );
  }
}
// API 形式
import {Dialog, Button} from 'path';

export default class DialogPage extends Component {
  render() {
    return (
      <div className='main'>
        <Button type='primary' onClick={() => {
          Dialog.show('title', 'content', [
          {
            text: '取消',
            onClick: () => {console.log('取消');}
          },
          {
            text: '确定',
            onClick: () => {console.log('确定');}
          }
          ]);
        }}>多个按钮</Button>
      </div>
    );
  }
}

项目目录


开发

命令脚本:

风格

TODO

重新定义组件开发原则,用于 v2.0.0 版

组件开发元素:

动画:

踩到的坑

addComponentAsRefTo Invariant Violation

竟然是 react-with-addonsreact-dom 加载顺序的问题 http://stackoverflow.com/questions/28519287/what-does-only-a-reactowner-can-have-refs-mean