graphql-react
Advanced tools
Comparing version 8.1.0 to 8.1.1
# graphql-react changelog | ||
## 8.1.1 | ||
### Patch | ||
- Updated a dev dependency. | ||
- Removed redundant `useGraphQL` internal `useEffect` React hook second arguments. | ||
- Fixed “Can't perform a React state update on an unmounted component” warnings if the component using the `useGraphQL` React hook is unmounted soon after an `GraphQL` instance event such as `reset` is emitted. | ||
## 8.1.0 | ||
@@ -4,0 +12,0 @@ |
{ | ||
"name": "graphql-react", | ||
"version": "8.1.0", | ||
"version": "8.1.1", | ||
"description": "A lightweight but powerful GraphQL client for React using modern context and hooks APIs; the first Relay and Apollo alternative with server side rendering.", | ||
@@ -62,3 +62,3 @@ "license": "MIT", | ||
"eslint-config-env": "^4.0.0", | ||
"eslint-config-prettier": "^4.0.0", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
@@ -65,0 +65,0 @@ "eslint-plugin-import-order-alphabetical": "^0.0.1", |
@@ -87,44 +87,44 @@ 'use strict' | ||
function onFetch(_ref2) { | ||
var fetchingCacheKey = _ref2.cacheKey | ||
if (cacheKey === fetchingCacheKey) setLoading(true) | ||
} | ||
_react.default.useEffect(function() { | ||
var mounted = true | ||
function onCache(_ref3) { | ||
var cachedCacheKey = _ref3.cacheKey, | ||
cacheValue = _ref3.cacheValue | ||
function onFetch(_ref2) { | ||
var fetchingCacheKey = _ref2.cacheKey | ||
if (cacheKey === fetchingCacheKey && mounted) setLoading(true) | ||
} | ||
if (cacheKey === cachedCacheKey) { | ||
setLoading(false) | ||
setCacheValue(cacheValue) | ||
function onCache(_ref3) { | ||
var cachedCacheKey = _ref3.cacheKey, | ||
cacheValue = _ref3.cacheValue | ||
if (cacheKey === cachedCacheKey && mounted) { | ||
setLoading(false) | ||
setCacheValue(cacheValue) | ||
} | ||
} | ||
} | ||
function onReload(_ref4) { | ||
var exceptCacheKey = _ref4.exceptCacheKey | ||
if (cacheKey !== exceptCacheKey && loadOnReload) load() | ||
} | ||
function onReload(_ref4) { | ||
var exceptCacheKey = _ref4.exceptCacheKey | ||
if (cacheKey !== exceptCacheKey && loadOnReload && mounted) load() | ||
} | ||
function onReset(_ref5) { | ||
var exceptCacheKey = _ref5.exceptCacheKey | ||
if (cacheKey !== exceptCacheKey) | ||
if (loadOnReset) load() | ||
else setCacheValue(graphql.cache[cacheKey]) | ||
} | ||
function onReset(_ref5) { | ||
var exceptCacheKey = _ref5.exceptCacheKey | ||
if (cacheKey !== exceptCacheKey && mounted) | ||
if (loadOnReset) load() | ||
else setCacheValue(graphql.cache[cacheKey]) | ||
} | ||
_react.default.useEffect( | ||
function() { | ||
graphql.on('fetch', onFetch) | ||
graphql.on('cache', onCache) | ||
graphql.on('reload', onReload) | ||
graphql.on('reset', onReset) | ||
return function() { | ||
graphql.off('fetch', onFetch) | ||
graphql.off('cache', onCache) | ||
graphql.off('reload', onReload) | ||
graphql.off('reset', onReset) | ||
} | ||
}, | ||
[graphql, onFetch, onCache, onReload, onReset] | ||
) | ||
graphql.on('fetch', onFetch) | ||
graphql.on('cache', onCache) | ||
graphql.on('reload', onReload) | ||
graphql.on('reset', onReset) | ||
return function() { | ||
mounted = false | ||
graphql.off('fetch', onFetch) | ||
graphql.off('cache', onCache) | ||
graphql.off('reload', onReload) | ||
graphql.off('reset', onReset) | ||
} | ||
}) | ||
@@ -135,11 +135,8 @@ var _React$useState4 = _react.default.useState(), | ||
_react.default.useEffect( | ||
function() { | ||
if (loadOnMount && cacheKey !== loadedOnMountCacheKey) { | ||
setLoadedOnMountCacheKey(cacheKey) | ||
load() | ||
} | ||
}, | ||
[loadOnMount, cacheKey, loadedOnMountCacheKey, load] | ||
) | ||
_react.default.useEffect(function() { | ||
if (loadOnMount && cacheKey !== loadedOnMountCacheKey) { | ||
setLoadedOnMountCacheKey(cacheKey) | ||
load() | ||
} | ||
}) | ||
@@ -146,0 +143,0 @@ if (graphql.ssr && loadOnMount && !cacheValue) operate() |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85416
763