UNPKG

@tanstack/react-query

Version:

Hooks for managing, caching and syncing asynchronous and remote data in React

68 lines (58 loc) 1.74 kB
/** * react-query * * Copyright (c) TanStack * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var React = require('react'); function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n["default"] = e; return Object.freeze(n); } var React__namespace = /*#__PURE__*/_interopNamespace(React); function createValue() { let isReset = false; return { clearReset: () => { isReset = false; }, reset: () => { isReset = true; }, isReset: () => { return isReset; } }; } const QueryErrorResetBoundaryContext = /*#__PURE__*/React__namespace.createContext(createValue()); // HOOK const useQueryErrorResetBoundary = () => React__namespace.useContext(QueryErrorResetBoundaryContext); // COMPONENT const QueryErrorResetBoundary = ({ children }) => { const [value] = React__namespace.useState(() => createValue()); return /*#__PURE__*/React__namespace.createElement(QueryErrorResetBoundaryContext.Provider, { value: value }, typeof children === 'function' ? children(value) : children); }; exports.QueryErrorResetBoundary = QueryErrorResetBoundary; exports.useQueryErrorResetBoundary = useQueryErrorResetBoundary; //# sourceMappingURL=QueryErrorResetBoundary.js.map