GitXplorerGitXplorer
l

react-dialog-queue

public
0 stars
3 forks
1 issues

Commits

List of commits on branch master.
Unverified
290b750c3a87d68ef2849d1ce61dbe80c4b50067

forgot to bulid....

llsslu committed 7 years ago
Unverified
da3ac786772395f06f05a341eb4aacbd729c425d

1.0.13

llsslu committed 7 years ago
Unverified
a27ab8c56c0536559e158381d59d26d8e4bcf080

open action: showDialog and hideDialog

llsslu committed 7 years ago
Unverified
111fa43c4ccc2129d679ddbb8281675f0b166f71

1.0.12

llsslu committed 7 years ago
Unverified
53e3b34ba869c14b8698f70a1c88eb50741d0c33

transfer event object to onclick

llsslu committed 7 years ago
Unverified
1f3aa57017fd1f710657f1de55ddd96b2f6c83e6

1.0.11

llsslu committed 7 years ago

README

The README file for this repository.

用途:

用以全局管理react项目中的弹出框,保持前台始终只显示一个弹出框。

用法:

  • 初始化reducer时注入dialogReducer
  const reducers = combineReducers({
    ...otherReducer,
    dialog: dialogReducer
  });
  • 根节点配置DialogQueue组件
  class App extends Component{
    render() {
      return (
        <div>
          <Route exact path="/" component={Home} />
          <DialogQueue />
        </div>
      );
    }
  }
  • 引入DialogTrigger组件,用以控制对话框的开关
  import { DialogTrigger } from 'react-dialog-queue';
  import MyDialog from '../components/dialog';

  class Test extends React.Component {

    render() {
      return (
        <div>
          <DialogTrigger type="show" cmpt={MyDialog}>
            <Button>show dialog</Button>
          </DialogTrigger>
        </div>
      );
    }
  }
  • Dialog组件中同样引入DialogTrigger,用以添加关闭按钮
  import { DialogTrigger } from 'react-dialog-queue';

  class MyDialog extends React.Component {

    render() {
      return (
        <Dialog {...this.props}>
          Hello Dialog~
          <DialogTrigger type="close">
            <Button>close</Button>
          </DialogTrigger>
        </Dialog>
      );
    }
  }

DialogTrigger 属性

  • type: 'show' | 'open' | 'close'
  • cmpt: 关联的Dialog组件类
  • data: 传给Dialog组件的数据,键值对

关闭Dialog

// close dialog through DialogTrigger
<DialogTrigger type="close">close dialog</DialogTrigger>
<DialogTrigger type="close" all>close all dialog</DialogTrigger>

// close dialog through dispatch an action
import { closeDialog } from 'react-dialog-queue';
import { connect } from 'react-redux';

class MyComponent extends React.Component { ... }

const mapDispatchToProps = (dispatch) => {
  return {
    closeDialog: (isCloseAll) => dispatch(closeDialog(isCloseAll))
  }
}

export default connect(null, mapDispatchToProps)(MyComponent);