您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

DialogContainer.js 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. /**
  4. * Implements a DialogContainer that will be responsible for
  5. * showing all dialogs. We will need a separate container so we can handle
  6. * multiple dialogs, showing them simultaneously or queueing them.
  7. */
  8. export class DialogContainer extends Component {
  9. /**
  10. * DialogContainer component's property types.
  11. *
  12. * @static
  13. */
  14. static propTypes = {
  15. /**
  16. * The component to render.
  17. */
  18. _component: React.PropTypes.func,
  19. /**
  20. * The props to pass to the component that will be rendered.
  21. */
  22. _componentProps: React.PropTypes.object
  23. };
  24. /**
  25. * Implements React's {@link Component#render()}.
  26. *
  27. * @inheritdoc
  28. * @returns {ReactElement}
  29. */
  30. render() {
  31. if (!this.props._component) {
  32. return null;
  33. }
  34. return React.createElement(
  35. this.props._component, this.props._componentProps);
  36. }
  37. }
  38. /**
  39. * Maps (parts of) the Redux state to the associated Dialog's props.
  40. *
  41. * @param {Object} state - The Redux state.
  42. * @private
  43. * @returns {{
  44. * _component: React.Component,
  45. * _props: React.PropTypes.object
  46. * }}
  47. */
  48. function _mapStateToProps(state) {
  49. return {
  50. _component: state['features/base/dialog'].component,
  51. _componentProps: state['features/base/dialog'].componentProps
  52. };
  53. }
  54. export default connect(_mapStateToProps)(DialogContainer);