fe7ff475271ee449f793084cabd39f5b.json
5.06 KB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useRef, useState, useEffect } from 'react';\nimport raf from \"rc-util/es/raf\";\nexport default function useRaf(callback) {\n var rafRef = useRef();\n var removedRef = useRef(false);\n\n function trigger() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n if (!removedRef.current) {\n raf.cancel(rafRef.current);\n rafRef.current = raf(function () {\n callback.apply(void 0, args);\n });\n }\n }\n\n useEffect(function () {\n return function () {\n removedRef.current = true;\n raf.cancel(rafRef.current);\n };\n }, []);\n return trigger;\n}\nexport function useRafState(defaultState) {\n var batchRef = useRef([]);\n\n var _useState = useState({}),\n _useState2 = _slicedToArray(_useState, 2),\n forceUpdate = _useState2[1];\n\n var state = useRef(typeof defaultState === 'function' ? defaultState() : defaultState);\n var flushUpdate = useRaf(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\n function updater(callback) {\n batchRef.current.push(callback);\n flushUpdate();\n }\n\n return [state.current, updater];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/rc-tabs/es/hooks/useRaf.js"],"names":["_slicedToArray","useRef","useState","useEffect","raf","useRaf","callback","rafRef","removedRef","trigger","_len","arguments","length","args","Array","_key","current","cancel","apply","useRafState","defaultState","batchRef","_useState","_useState2","forceUpdate","state","flushUpdate","forEach","updater","push"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,0CAA3B;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,OAA5C;AACA,OAAOC,GAAP,MAAgB,gBAAhB;AACA,eAAe,SAASC,MAAT,CAAgBC,QAAhB,EAA0B;AACvC,MAAIC,MAAM,GAAGN,MAAM,EAAnB;AACA,MAAIO,UAAU,GAAGP,M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AAY;AACnC,QAAIW,OAAO,GAAGS,KAAK,CAACT,OAApB;AACAK,IAAAA,QAAQ,CAACL,OAAT,CAAiBW,OAAjB,CAAyB,UAAUrB,QAAV,EAAoB;AAC3CU,MAAAA,OAAO,GAAGV,QAAQ,CAACU,OAAD,CAAlB;AACD,KAFD;AAGAK,IAAAA,QAAQ,CAACL,OAAT,GAAmB,EAAnB;AACAS,IAAAA,KAAK,CAACT,OAAN,GAAgBA,OAAhB;AACAQ,IAAAA,WAAW,CAAC,EAAD,CAAX;AACD,GARuB,CAAxB;;AAUA,WAASI,OAAT,CAAiBtB,QAAjB,EAA2B;AACzBe,IAAAA,QAAQ,CAACL,OAAT,CAAiBa,IAAjB,CAAsBvB,QAAtB;AACAoB,IAAAA,WAAW;AACZ;;AAED,SAAO,CAACD,KAAK,CAACT,OAAP,EAAgBY,OAAhB,CAAP;AACD","sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport { useRef, useState, useEffect } from 'react';\nimport raf from \"rc-util/es/raf\";\nexport default function useRaf(callback) {\n var rafRef = useRef();\n var removedRef = useRef(false);\n\n function trigger() {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n if (!removedRef.current) {\n raf.cancel(rafRef.current);\n rafRef.current = raf(function () {\n callback.apply(void 0, args);\n });\n }\n }\n\n useEffect(function () {\n return function () {\n removedRef.current = true;\n raf.cancel(rafRef.current);\n };\n }, []);\n return trigger;\n}\nexport function useRafState(defaultState) {\n var batchRef = useRef([]);\n\n var _useState = useState({}),\n _useState2 = _slicedToArray(_useState, 2),\n forceUpdate = _useState2[1];\n\n var state = useRef(typeof defaultState === 'function' ? defaultState() : defaultState);\n var flushUpdate = useRaf(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\n function updater(callback) {\n batchRef.current.push(callback);\n flushUpdate();\n }\n\n return [state.current, updater];\n}"]},"metadata":{},"sourceType":"module"}