@opensea/react-media
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -1,3 +0,4 @@ | ||
import React$1, { useReducer, useEffect, useState } from 'react'; | ||
import { useReducer, useEffect, useState } from 'react'; | ||
import { useContextSelector, createContext } from 'use-context-selector'; | ||
import { jsx, Fragment } from 'react/jsx-runtime'; | ||
import throttle from 'lodash.throttle'; | ||
@@ -87,7 +88,10 @@ | ||
if (typeof children === 'function') { | ||
return /*#__PURE__*/React$1.createElement(Fragment, null, children(mediaClassName)); | ||
return /*#__PURE__*/jsx(Fragment, { | ||
children: children(mediaClassName) | ||
}); | ||
} else { | ||
return /*#__PURE__*/React$1.createElement("div", { | ||
className: mediaClassName | ||
}, children); | ||
return /*#__PURE__*/jsx("div", { | ||
className: mediaClassName, | ||
children: children | ||
}); | ||
} | ||
@@ -136,5 +140,6 @@ }; | ||
const windowSize = useWindowSize(initialWindowSize); | ||
return /*#__PURE__*/React.createElement(SizeContext.Provider, { | ||
value: windowSize | ||
}, children); | ||
return /*#__PURE__*/jsx(SizeContext.Provider, { | ||
value: windowSize, | ||
children: children | ||
}); | ||
}; | ||
@@ -141,0 +146,0 @@ return { |
@@ -1,3 +0,4 @@ | ||
import React$1, { useReducer, useEffect, useState } from 'react'; | ||
import { useReducer, useEffect, useState } from 'react'; | ||
import { useContextSelector, createContext } from 'use-context-selector'; | ||
import { jsx, Fragment } from 'react/jsx-runtime'; | ||
import throttle from 'lodash.throttle'; | ||
@@ -93,7 +94,10 @@ | ||
if (typeof children === 'function') { | ||
return /*#__PURE__*/React$1.createElement(Fragment, null, children(mediaClassName)); | ||
return /*#__PURE__*/jsx(Fragment, { | ||
children: children(mediaClassName) | ||
}); | ||
} else { | ||
return /*#__PURE__*/React$1.createElement("div", { | ||
className: mediaClassName | ||
}, children); | ||
return /*#__PURE__*/jsx("div", { | ||
className: mediaClassName, | ||
children: children | ||
}); | ||
} | ||
@@ -147,5 +151,6 @@ }; | ||
var windowSize = useWindowSize(initialWindowSize); | ||
return /*#__PURE__*/React.createElement(SizeContext.Provider, { | ||
value: windowSize | ||
}, children); | ||
return /*#__PURE__*/jsx(SizeContext.Provider, { | ||
value: windowSize, | ||
children: children | ||
}); | ||
}; | ||
@@ -152,0 +157,0 @@ return { |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('use-context-selector'), require('lodash.throttle')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'use-context-selector', 'lodash.throttle'], factory) : | ||
(global = global || self, factory(global.reactMedia = {}, global.react, global.useContextSelector, global.throttle)); | ||
})(this, (function (exports, React$1, useContextSelector, throttle) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('use-context-selector'), require('react/jsx-runtime'), require('lodash.throttle')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'react', 'use-context-selector', 'react/jsx-runtime', 'lodash.throttle'], factory) : | ||
(global = global || self, factory(global.reactMedia = {}, global.react, global.useContextSelector, global.jsx, global.throttle)); | ||
})(this, (function (exports, react, useContextSelector, jsxRuntime, throttle) { | ||
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1); | ||
var throttle__default = /*#__PURE__*/_interopDefaultLegacy(throttle); | ||
@@ -13,7 +12,7 @@ | ||
var useIsHydrated = function useIsHydrated() { | ||
var _useReducer = React$1.useReducer(function (x) { | ||
var _useReducer = react.useReducer(function (x) { | ||
return x + 1; | ||
}, 0), | ||
forceUpdate = _useReducer[1]; | ||
React$1.useEffect(function () { | ||
react.useEffect(function () { | ||
if (!isHydrated) { | ||
@@ -100,7 +99,10 @@ isHydrated = true; | ||
if (typeof children === 'function') { | ||
return /*#__PURE__*/React__default["default"].createElement(Fragment, null, children(mediaClassName)); | ||
return /*#__PURE__*/jsxRuntime.jsx(jsxRuntime.Fragment, { | ||
children: children(mediaClassName) | ||
}); | ||
} else { | ||
return /*#__PURE__*/React__default["default"].createElement("div", { | ||
className: mediaClassName | ||
}, children); | ||
return /*#__PURE__*/jsxRuntime.jsx("div", { | ||
className: mediaClassName, | ||
children: children | ||
}); | ||
} | ||
@@ -118,6 +120,6 @@ }; | ||
} | ||
var _useState = React$1.useState(initialWindowSize), | ||
var _useState = react.useState(initialWindowSize), | ||
windowSize = _useState[0], | ||
setWindowSize = _useState[1]; | ||
React$1.useEffect(function () { | ||
react.useEffect(function () { | ||
var handleResize = function handleResize() { | ||
@@ -155,5 +157,6 @@ setWindowSize({ | ||
var windowSize = useWindowSize(initialWindowSize); | ||
return /*#__PURE__*/React.createElement(SizeContext.Provider, { | ||
value: windowSize | ||
}, children); | ||
return /*#__PURE__*/jsxRuntime.jsx(SizeContext.Provider, { | ||
value: windowSize, | ||
children: children | ||
}); | ||
}; | ||
@@ -160,0 +163,0 @@ return { |
{ | ||
"name": "@opensea/react-media", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Javascript library to deal with media queries in isomorphic React applications.", | ||
@@ -19,3 +19,3 @@ "license": "MIT", | ||
"scripts": { | ||
"build": "microbundle --no-compress --sourcemap false --jsx 'React.createElement'", | ||
"build": "microbundle --no-compress --sourcemap false --jsx jsx --jsxImportSource react --globals react/jsx-runtime=jsx", | ||
"check-types": "tsc --noEmit", | ||
@@ -22,0 +22,0 @@ "lint": "concurrently \"npm run check-types\" \"npm run prettier:check\" \"npm run prettier:package.json:check\"", |
Sorry, the diff of this file is not supported yet
51903
1205