jiti-meet/react/features/overlay/components/OverlayContainer.js

62 lines
1.4 KiB
JavaScript
Raw Normal View History

2017-11-29 10:48:10 +00:00
// @flow
import React, { Component } from 'react';
2019-03-21 16:38:29 +00:00
import { connect } from '../../base/redux';
2018-06-14 09:14:32 +00:00
import { getOverlayToRender } from '../functions';
2017-11-29 10:48:10 +00:00
declare var interfaceConfig: Object;
/**
2017-11-30 04:13:24 +00:00
* The type of the React {@link Component} props of {@code OverlayContainer}.
*/
2017-11-29 10:48:10 +00:00
type Props = {
/**
2017-11-30 04:13:24 +00:00
* The React {@link Component} type of overlay to be rendered by the
* associated {@code OverlayContainer}.
*/
2017-11-30 04:13:24 +00:00
overlay: ?React$ComponentType<*>
2017-11-29 10:48:10 +00:00
}
2017-11-29 10:48:10 +00:00
/**
* Implements a React {@link Component} that will display the correct overlay
* when needed.
*/
class OverlayContainer extends Component<Props> {
/**
* Implements React's {@link Component#render()}.
*
* @inheritdoc
* @public
* @returns {ReactElement|null}
*/
render() {
const { overlay } = this.props;
return overlay ? React.createElement(overlay, {}) : null;
}
}
/**
* Maps (parts of) the redux state to the associated {@code OverlayContainer}'s
* props.
*
* @param {Object} state - The redux state.
* @private
* @returns {{
* overlay: ?Object
* }}
*/
function _mapStateToProps(state) {
return {
/**
* The React {@link Component} type of overlay to be rendered by the
* associated {@code OverlayContainer}.
*/
2018-06-14 09:14:32 +00:00
overlay: getOverlayToRender(state)
};
}
export default connect(_mapStateToProps)(OverlayContainer);