wix-style-react
Version:
wix-style-react
19 lines • 743 B
JavaScript
import React from 'react';
import PropTypes from 'prop-types';
import { InputContext } from '../InputContext';
export const InputConsumer = ({ consumerCompName = 'InputConsumer', children, }) => {
if (typeof children !== 'function') {
throw new Error(`child of ${consumerCompName} must be a context consumer function`);
}
return (React.createElement(InputContext.Consumer, null, context => {
if (!context) {
throw new Error(`${consumerCompName} cannot be rendered outside the Input component`);
}
return children(context);
}));
};
InputConsumer.propTypes = {
children: PropTypes.any.isRequired,
consumerCompName: PropTypes.string,
};
//# sourceMappingURL=InputConsumer.js.map