react-native-full-responsive
Version:
Create a fully responsive React Native app for all supported platforms
19 lines • 1.06 kB
JavaScript
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React from 'react';
import { useMediaQuery } from '../hooks';
/**
* A HOC for when you want to use full responsive methods in your class components without additional steps as props.
*/
const withMediaQuery = (Component, thresholds) => {
const displayName = Component.displayName || Component.name || 'Component';
const ComponentWithMethods = props => {
const media = useMediaQuery(thresholds);
return /*#__PURE__*/React.createElement(Component, _extends({}, props, {
type: media
}));
};
ComponentWithMethods.displayName = `withMediaQuery(${displayName})`;
return ComponentWithMethods;
};
export { withMediaQuery, withMediaQuery as withMQ };
//# sourceMappingURL=withMediaQuery.js.map