e92ee201ef62dc0c4551de411c8aec20.json
4.14 KB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport { useRef } from 'react';\nimport raf from \"rc-util/es/raf\";\nexport default function useFrameState(defaultValue) {\n var _React$useState = React.useState(defaultValue),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n value = _React$useState2[0],\n setValue = _React$useState2[1];\n\n var frameRef = useRef(null);\n var batchRef = useRef([]);\n var destroyRef = useRef(false);\n React.useEffect(function () {\n return function () {\n destroyRef.current = true;\n raf.cancel(frameRef.current);\n };\n }, []);\n\n function setFrameValue(updater) {\n if (destroyRef.current) {\n return;\n }\n\n if (frameRef.current === null) {\n batchRef.current = [];\n frameRef.current = raf(function () {\n frameRef.current = null;\n setValue(function (prevValue) {\n var current = prevValue;\n batchRef.current.forEach(function (func) {\n current = func(current);\n });\n return current;\n });\n });\n }\n\n batchRef.current.push(updater);\n }\n\n return [value, setFrameValue];\n}","map":{"version":3,"sources":["C:/Users/kkwan_000/Desktop/git/2017110269/minsung/node_modules/antd/es/form/hooks/useFrameState.js"],"names":["_slicedToArray","React","useRef","raf","useFrameState","defaultValue","_React$useState","useState","_React$useState2","value","setValue","frameRef","batchRef","destroyRef","useEffect","current","cancel","setFrameValue","updater","prevValue","forEach","func","push"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,sCAA3B;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AACA,SAASC,MAAT,QAAuB,OAAvB;AACA,OAAOC,GAAP,MAAgB,gBAAhB;AACA,eAAe,SAASC,aAAT,CAAuBC,YAAvB,EAAqC;AAClD,MAAIC,eAAe,GAAGL,KAAK,CAACM,QAAN,CAAeF,YAAf,CAAtB;AAAA,MACIG,gBAAgB,GAAGR,cAAc,CAACM,eAAD,EAAkB,CAAlB,CADrC;AAAA,MAEIG,KAAK,GAAGD,gBAAgB,CAAC,CAAD,CAF5B;AAAA,MAGIE,QAAQ,GAAGF,gBAAgB,CAAC,CAAD,CAH/B;;AAKA,MAAIG,QAAQ,GAAGT,MAAM,CAAC,IAAD,CAArB;AACA,MAAIU,QAAQ,GAAGV,MAAM,CAAC,EAAD,CAArB;AACA,MAAIW,UAAU,GAAGX,MAAM,CAAC,KAAD,CAAvB;AACAD,EAAAA,KAAK,CAACa,SAAN,CAAgB,YAAY;AAC1B,WAAO,YAAY;AACjBD,MAAAA,UAAU,CAACE,OAAX,GAAqB,IAArB;AACAZ,MAAAA,GAAG,CAACa,MAAJ,CAAWL,QAAQ,CAACI,OAApB;AACD,KAHD;AAID,GALD,EAKG,EALH;;AAOA,WAASE,aAAT,CAAuBC,OAAvB,EAAgC;AAC9B,QAAIL,UAAU,CAACE,OAAf,EAAwB;AACtB;AACD;;AAED,QAAIJ,QAAQ,CAACI,OAAT,KAAqB,IAAzB,EAA+B;AAC7BH,MAAAA,QAAQ,CAACG,OAAT,GAAmB,EAAnB;AACAJ,MAAAA,QAAQ,CAACI,OAAT,GAAmBZ,GAAG,CAAC,YAAY;AACjCQ,QAAAA,QAAQ,CAACI,OAAT,GAAmB,IAAnB;AACAL,QAAAA,QAAQ,CAAC,UAAUS,SAAV,EAAqB;AAC5B,cAAIJ,OAAO,GAAGI,SAAd;AACAP,UAAAA,QAAQ,CAACG,OAAT,CAAiBK,OAAjB,CAAyB,UAAUC,IAAV,EAAgB;AACvCN,YAAAA,OAAO,GAAGM,IAAI,CAACN,OAAD,CAAd;AACD,WAFD;AAGA,iBAAOA,OAAP;AACD,SANO,CAAR;AAOD,OATqB,CAAtB;AAUD;;AAEDH,IAAAA,QAAQ,CAACG,OAAT,CAAiBO,IAAjB,CAAsBJ,OAAtB;AACD;;AAED,SAAO,CAACT,KAAD,EAAQQ,aAAR,CAAP;AACD","sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport * as React from 'react';\nimport { useRef } from 'react';\nimport raf from \"rc-util/es/raf\";\nexport default function useFrameState(defaultValue) {\n var _React$useState = React.useState(defaultValue),\n _React$useState2 = _slicedToArray(_React$useState, 2),\n value = _React$useState2[0],\n setValue = _React$useState2[1];\n\n var frameRef = useRef(null);\n var batchRef = useRef([]);\n var destroyRef = useRef(false);\n React.useEffect(function () {\n return function () {\n destroyRef.current = true;\n raf.cancel(frameRef.current);\n };\n }, []);\n\n function setFrameValue(updater) {\n if (destroyRef.current) {\n return;\n }\n\n if (frameRef.current === null) {\n batchRef.current = [];\n frameRef.current = raf(function () {\n frameRef.current = null;\n setValue(function (prevValue) {\n var current = prevValue;\n batchRef.current.forEach(function (func) {\n current = func(current);\n });\n return current;\n });\n });\n }\n\n batchRef.current.push(updater);\n }\n\n return [value, setFrameValue];\n}"]},"metadata":{},"sourceType":"module"}