@brightleaf/react-hooks
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -54,12 +54,6 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "useGraphQL", { | ||
enumerable: true, | ||
get: function () { | ||
return _useGraphql.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useQuery", { | ||
enumerable: true, | ||
get: function () { | ||
return _useGraphql.useQuery; | ||
return _useQuery.useQuery; | ||
} | ||
@@ -91,8 +85,2 @@ }); | ||
}); | ||
Object.defineProperty(exports, "useMutation", { | ||
enumerable: true, | ||
get: function () { | ||
return _useMutation.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "useNes", { | ||
@@ -181,3 +169,3 @@ enumerable: true, | ||
var _useGraphql = _interopRequireWildcard(require("./use-graphql")); | ||
var _useQuery = require("./use-query"); | ||
@@ -192,4 +180,2 @@ var _useKeypressed = _interopRequireDefault(require("./use-keypressed")); | ||
var _useMutation = _interopRequireDefault(require("./use-mutation")); | ||
var _useNes = _interopRequireDefault(require("./use-nes")); | ||
@@ -217,6 +203,2 @@ | ||
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.useQuery = exports.default = exports.useGraphQL = void 0; | ||
exports.default = exports.useGraphQL = void 0; | ||
@@ -13,6 +13,2 @@ var _graphqlRequest = require("graphql-request"); | ||
var _useRequest = require("./use-request"); | ||
var _mergeDeep = require("./utils/merge-deep"); | ||
const reducer = (state, action) => { | ||
@@ -97,48 +93,2 @@ switch (action.type) { | ||
var _default = useGraphQL; | ||
exports.default = _default; | ||
const defaultConfig = { | ||
method: 'POST', | ||
mode: 'cors', | ||
cache: 'no-cache', | ||
credentials: 'same-origin', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
redirect: 'follow', | ||
referrer: 'no-referrer' | ||
}; | ||
const useQuery = (url = '/graphql', query, config = { | ||
method: 'POST' | ||
}) => { | ||
const { | ||
makeRequest, | ||
...props | ||
} = (0, _useRequest.useRequest)(url, { | ||
data: null, | ||
error: null, | ||
loading: false | ||
}); | ||
const fullConfig = (0, _mergeDeep.mergeDeep)(defaultConfig, config); | ||
/** | ||
* postData - Post data to url | ||
* | ||
* @param {object} data - the data to post | ||
*/ | ||
const makeQuery = async variables => { | ||
await makeRequest({ ...fullConfig, | ||
body: JSON.stringify({ | ||
query, | ||
variables | ||
}) | ||
}); | ||
}; | ||
return { | ||
makeQuery, | ||
...props | ||
}; | ||
}; | ||
exports.useQuery = useQuery; | ||
exports.default = _default; |
{ | ||
"name": "@brightleaf/react-hooks", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Useful react hooks", | ||
@@ -5,0 +5,0 @@ "files": [ |
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
41
117700
3579