wix-style-react
Version:
wix-style-react
30 lines (27 loc) • 929 B
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import { BulkSelectionContext } from './BulkSelection';
export var BulkSelectionConsumer = function BulkSelectionConsumer(props) {
if (typeof props.children !== 'function') {
throw new Error('child of ' + props.consumerCompName + ' must be a context consumer function');
}
return React.createElement(
BulkSelectionContext.Consumer,
null,
function (context) {
if (!context) {
throw new Error(props.consumerCompName + ' cannot be rendered outside the ' + props.providerCompName + ' component');
}
return props.children(context);
}
);
};
BulkSelectionConsumer.propTypes = {
children: PropTypes.any.isRequired,
consumerCompName: PropTypes.string,
providerCompName: PropTypes.string
};
BulkSelectionConsumer.defaultProps = {
consumerCompName: 'BulkSelectionConsumer',
providerCompName: 'BulkSelection'
};