PromoCursed/node_modules/.cache/babel-loader/47dc4fce91108608fc44a1cb88afac65500a902087fb074a5bb25bf1d2a35517.json

1 line
5.5 KiB
JSON
Raw Normal View History

2024-08-20 23:25:37 +04:00
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useLayoutUpdateEffect } from \"rc-util/es/hooks/useLayoutEffect\";\nimport { useRef, useState } from 'react';\n\n/**\n * Help to merge callback with `useLayoutEffect`.\n * One time will only trigger once.\n */\nexport default function useUpdate(callback) {\n var _useState = useState(0),\n _useState2 = _slicedToArray(_useState, 2),\n count = _useState2[0],\n setCount = _useState2[1];\n var effectRef = useRef(0);\n var callbackRef = useRef();\n callbackRef.current = callback;\n\n // Trigger on `useLayoutEffect`\n useLayoutUpdateEffect(function () {\n var _callbackRef$current;\n (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 || _callbackRef$current.call(callbackRef);\n }, [count]);\n\n // Trigger to update count\n return function () {\n if (effectRef.current !== count) {\n return;\n }\n effectRef.current += 1;\n setCount(effectRef.current);\n };\n}\nexport function useUpdateState(defaultState) {\n var batchRef = useRef([]);\n var _useState3 = useState({}),\n _useState4 = _slicedToArray(_useState3, 2),\n forceUpdate = _useState4[1];\n var state = useRef(typeof defaultState === 'function' ? defaultState() : defaultState);\n var flushUpdate = useUpdate(function () {\n var current = state.current;\n batchRef.current.forEach(function (callback) {\n current = callback(current);\n });\n batchRef.current = [];\n state.current = current;\n forceUpdate({});\n });\n function updater(callback) {\n batchRef.current.push(callback);\n flushUpdate();\n }\n return [state.current, updater];\n}","map":{"version":3,"names":["_slicedToArray","useLayoutUpdateEffect","useRef","useState","useUpdate","callback","_useState","_useState2","count","setCount","effectRef","callbackRef","current","_callbackRef$current","call","useUpdateState","defaultState","batchRef","_useState3","_useState4","forceUpdate","state","flushUpdate","forEach","updater","push"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/rc-tabs/es/hooks/useUpdate.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useLayoutUpdateEffect } from \"rc-util/es/hooks/useLayoutEffect\";\nimport { useRef, useState } from 'react';\n\n/**\n * Help to merge callback with `useLayoutEffect`.\n * One time will only trigger once.\n */\nexport default function useUpdate(callback) {\n var _useState = useState(0),\n _useState2 = _slicedToArray(_useState, 2),\n count = _useState2[0],\n setCount = _useState2[1];\n var effectRef = useRef(0);\n var callbackRef = useRef();\n callbackRef.current = callback;\n\n // Trigger on `useLayoutEffect`\n useLayoutUpdateEffect(function () {\n var _callbackRef$current;\n (_callbackRef$current = callbackRef.current) === null || _callbackRef$current === void 0 || _callbackRef$current.call(callbackRef);\n }, [count]);\n\n // Trigger to update count\n return function () {\n if (effectRef.current !== count) {\n return;\n }\n effectRef.current += 1;\n setCount(effectRef.current);\n };\n}\nexport function useUpdateState(defaultState) {\n var batchRef = useRef([]);\n var _useState3 = useState({}),\n _useState4 = _slicedToArray(_useState3, 2),\n forceUpdate = _useState4[1];\n var state = useRef(typeof defaultState === 'function' ? defaultState() : defaultState);\n var flushUpdate = useUpdate(function () {\n var current = state.current;\n batchRef.current.forEach(function (callback) {\n current = callback(current);\n });\n batchRef.current = [];\n state.current = current;\n forceUpdate({});\n });\n function updater(callback) {\n batchRef.current.push(callback);\n flushUpdate();\n }\n return [state.current, updater];\n}"],"mappings":"AAAA,OAAOA,cAAc,MAAM,0CAA0C;AACrE,SAASC,qBAAqB,QAAQ,kCAAkC;AACxE,SAASC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;;AAExC;AACA;AACA;AACA;AACA,eAAe,SAASC,SAASA,CAACC,QAAQ,EAAE;EAC1C,