create-api-hooks
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -8,3 +8,4 @@ import { useEffect, useState, useCallback, useRef } from 'react'; | ||
var _b = _a === void 0 ? {} : _a, _c = _b.cache, cache = _c === void 0 ? true : _c, _d = _b.initValue, initValue = _d === void 0 ? {} : _d, params = _b.params, _e = _b.needInit, needInit = _e === void 0 ? true : _e; | ||
initValue = cache && needInit ? cacheObj[requestName] || initValue : initValue; | ||
initValue = | ||
cache && needInit ? cacheObj[requestName] || initValue : initValue; | ||
var _f = useState(), error = _f[0], setError = _f[1]; | ||
@@ -72,8 +73,6 @@ var _g = useState(initValue), data = _g[0], setData = _g[1]; | ||
var result = Hooks; | ||
result.request = function (params) { | ||
return request(params).then(function (_a) { | ||
var data = _a.data; | ||
return Promise.resolve(data); | ||
}); | ||
}; | ||
result.request = useCallback(function (params) { return request(params).then(function (_a) { | ||
var data = _a.data; | ||
return Promise.resolve(data); | ||
}); }, [request]); | ||
return result; | ||
@@ -80,0 +79,0 @@ } |
@@ -12,3 +12,4 @@ 'use strict'; | ||
var _b = _a === void 0 ? {} : _a, _c = _b.cache, cache = _c === void 0 ? true : _c, _d = _b.initValue, initValue = _d === void 0 ? {} : _d, params = _b.params, _e = _b.needInit, needInit = _e === void 0 ? true : _e; | ||
initValue = cache && needInit ? cacheObj[requestName] || initValue : initValue; | ||
initValue = | ||
cache && needInit ? cacheObj[requestName] || initValue : initValue; | ||
var _f = react.useState(), error = _f[0], setError = _f[1]; | ||
@@ -76,8 +77,6 @@ var _g = react.useState(initValue), data = _g[0], setData = _g[1]; | ||
var result = Hooks; | ||
result.request = function (params) { | ||
return request(params).then(function (_a) { | ||
var data = _a.data; | ||
return Promise.resolve(data); | ||
}); | ||
}; | ||
result.request = react.useCallback(function (params) { return request(params).then(function (_a) { | ||
var data = _a.data; | ||
return Promise.resolve(data); | ||
}); }, [request]); | ||
return result; | ||
@@ -84,0 +83,0 @@ } |
{ | ||
"name": "create-api-hooks", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "mushan0x0", |
Sorry, the diff of this file is not supported yet
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
22347
193