@schibstedspain/sui-react-hooks
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -5,14 +5,23 @@ # Change Log | ||
<a name="1.6.0"></a> | ||
# 1.7.0 (2020-02-04) | ||
# 1.6.0 (2019-11-18) | ||
### Bug Fixes | ||
* fix temporaly to use async effects and clean effects ([c04a37b](https://github.com/SUI-Components/schibsted-spain-components/commit/c04a37b105ebec673ec224e314d6962ab610458d)) | ||
* fix useMount effect with clear effect ([cfb100a](https://github.com/SUI-Components/schibsted-spain-components/commit/cfb100a4e0e3895ed8554514b19f94aae501d7e9)) | ||
### Features | ||
* show message only on other than production to remove the dead code on pro ([d488b42](https://github.com/SUI-Components/schibsted-spain-components/commit/d488b42)) | ||
* update intersection-observer version ([35714ec](https://github.com/SUI-Components/schibsted-spain-components/commit/35714ec)) | ||
* add temporary solution for add compatibility ([f378268](https://github.com/SUI-Components/schibsted-spain-components/commit/f3782687777bbc233579508d7e0a37afbc16cb7b)) | ||
* show message only on other than production to remove the dead code on pro ([d488b42](https://github.com/SUI-Components/schibsted-spain-components/commit/d488b426a693e45bbf24fe94d2be1c8e64c7dbd6)) | ||
* update intersection-observer version ([35714ec](https://github.com/SUI-Components/schibsted-spain-components/commit/35714ecdd2dcefee28d30ba5b13b412115a894ea)) | ||
<a name="1.5.0"></a> | ||
# 1.5.0 (2019-07-24) | ||
@@ -23,7 +32,6 @@ | ||
* make sure legacy state hook extends the most updated state ([3467709](https://github.com/SUI-Components/schibsted-spain-components/commit/3467709)) | ||
* make sure legacy state hook extends the most updated state ([3467709](https://github.com/SUI-Components/schibsted-spain-components/commit/3467709ad4bebf6e1696a9d23f47b2e479a9226d)) | ||
<a name="1.4.0"></a> | ||
# 1.4.0 (2019-07-23) | ||
@@ -34,8 +42,7 @@ | ||
* add a new useStateReducer hook ([579999c](https://github.com/SUI-Components/schibsted-spain-components/commit/579999c)) | ||
* rename useStateReducer to useLegacyState ([83d0b35](https://github.com/SUI-Components/schibsted-spain-components/commit/83d0b35)) | ||
* add a new useStateReducer hook ([579999c](https://github.com/SUI-Components/schibsted-spain-components/commit/579999cd9db778cf3dc3c92066c1c7d8fffdbb67)) | ||
* rename useStateReducer to useLegacyState ([83d0b35](https://github.com/SUI-Components/schibsted-spain-components/commit/83d0b359060443a6ea50ef1b4917db2a222b534d)) | ||
<a name="1.3.0"></a> | ||
# 1.3.0 (2019-06-25) | ||
@@ -46,7 +53,6 @@ | ||
* fix missing brackets ([f467719](https://github.com/SUI-Components/schibsted-spain-components/commit/f467719)) | ||
* fix missing brackets ([f467719](https://github.com/SUI-Components/schibsted-spain-components/commit/f4677198cc90a54ccebc5c550a96b263bbb01bbe)) | ||
<a name="1.2.0"></a> | ||
# 1.2.0 (2019-06-25) | ||
@@ -57,7 +63,6 @@ | ||
* adaptation to be able to execute asynchronous functions ([70b94a1](https://github.com/SUI-Components/schibsted-spain-components/commit/70b94a1)) | ||
* adaptation to be able to execute asynchronous functions ([70b94a1](https://github.com/SUI-Components/schibsted-spain-components/commit/70b94a1198c72cbf7f994efa9d61b31a02ec0a93)) | ||
<a name="1.1.0"></a> | ||
# 1.1.0 (2019-05-21) | ||
@@ -68,6 +73,6 @@ | ||
* add some react hooks useMount and useNearScreen ([0938603](https://github.com/SUI-Components/schibsted-spain-components/commit/0938603)) | ||
* export all hooks ([c21236f](https://github.com/SUI-Components/schibsted-spain-components/commit/c21236f)) | ||
* add some react hooks useMount and useNearScreen ([0938603](https://github.com/SUI-Components/schibsted-spain-components/commit/0938603b54e54fe0aa3f814e7de918351a01fe50)) | ||
* export all hooks ([c21236f](https://github.com/SUI-Components/schibsted-spain-components/commit/c21236f0701038e1f2e0e69c7f97887ccc587598)) | ||
@@ -1,3 +0,7 @@ | ||
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread"; | ||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
import { useState } from 'react'; | ||
@@ -10,9 +14,8 @@ export default function useLegacyState(initialState) { | ||
var _useState = useState(initialState), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
state = _useState2[0], | ||
setState = _useState2[1]; | ||
state = _useState[0], | ||
setState = _useState[1]; | ||
var setLegacyState = function setLegacyState(newState) { | ||
return setState(function (prevState) { | ||
return _objectSpread({}, prevState, newState); | ||
return _objectSpread({}, prevState, {}, newState); | ||
}); | ||
@@ -19,0 +22,0 @@ }; |
@@ -0,6 +1,41 @@ | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
import { useEffect } from 'react'; | ||
export default function useMount(effect) { | ||
useEffect(function () { | ||
effect(); | ||
var clean = function clean() {}; | ||
function doEffect() { | ||
return _doEffect.apply(this, arguments); | ||
} | ||
function _doEffect() { | ||
_doEffect = _asyncToGenerator( | ||
/*#__PURE__*/ | ||
_regeneratorRuntime.mark(function _callee() { | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return effect(); | ||
case 2: | ||
clean = _context.sent; | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
return _doEffect.apply(this, arguments); | ||
} | ||
doEffect(); | ||
return function () { | ||
return typeof clean === 'function' && clean(); | ||
}; | ||
}, []); // eslint-disable-line | ||
} |
@@ -1,2 +0,1 @@ | ||
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray"; | ||
import { useEffect, useRef, useState } from 'react'; | ||
@@ -24,5 +23,4 @@ import PropTypes from 'prop-types'; | ||
var _useState = useState(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
isIntersecting = _useState2[0], | ||
setIntersecting = _useState2[1]; | ||
isIntersecting = _useState[0], | ||
setIntersecting = _useState[1]; | ||
@@ -40,5 +38,3 @@ var outerRef = useRef(); | ||
observer = new window.IntersectionObserver(function (_ref4) { | ||
var _ref5 = _slicedToArray(_ref4, 1), | ||
entry = _ref5[0]; | ||
var entry = _ref4[0]; | ||
// Update our state when observer callback fires | ||
@@ -45,0 +41,0 @@ setIntersecting(entry.isIntersecting); |
{ | ||
"name": "@schibstedspain/sui-react-hooks", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
11642
115