1 line
3.6 KiB
JSON
1 line
3.6 KiB
JSON
{"ast":null,"code":"import * as React from 'react';\nimport { useRef } from 'react';\nimport raf from \"rc-util/es/raf\";\nexport default function useFrameState(defaultValue) {\n const [value, setValue] = React.useState(defaultValue);\n const frameRef = useRef(null);\n const batchRef = useRef([]);\n const destroyRef = useRef(false);\n React.useEffect(() => {\n destroyRef.current = false;\n return () => {\n destroyRef.current = true;\n raf.cancel(frameRef.current);\n frameRef.current = null;\n };\n }, []);\n function setFrameValue(updater) {\n if (destroyRef.current) {\n return;\n }\n if (frameRef.current === null) {\n batchRef.current = [];\n frameRef.current = raf(() => {\n frameRef.current = null;\n setValue(prevValue => {\n let current = prevValue;\n batchRef.current.forEach(func => {\n current = func(current);\n });\n return current;\n });\n });\n }\n batchRef.current.push(updater);\n }\n return [value, setFrameValue];\n}","map":{"version":3,"names":["React","useRef","raf","useFrameState","defaultValue","value","setValue","useState","frameRef","batchRef","destroyRef","useEffect","current","cancel","setFrameValue","updater","prevValue","forEach","func","push"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/form/hooks/useFrameState.js"],"sourcesContent":["import * as React from 'react';\nimport { useRef } from 'react';\nimport raf from \"rc-util/es/raf\";\nexport default function useFrameState(defaultValue) {\n const [value, setValue] = React.useState(defaultValue);\n const frameRef = useRef(null);\n const batchRef = useRef([]);\n const destroyRef = useRef(false);\n React.useEffect(() => {\n destroyRef.current = false;\n return () => {\n destroyRef.current = true;\n raf.cancel(frameRef.current);\n frameRef.current = null;\n };\n }, []);\n function setFrameValue(updater) {\n if (destroyRef.current) {\n return;\n }\n if (frameRef.current === null) {\n batchRef.current = [];\n frameRef.current = raf(() => {\n frameRef.current = null;\n setValue(prevValue => {\n let current = prevValue;\n batchRef.current.forEach(func => {\n current = func(current);\n });\n return current;\n });\n });\n }\n batchRef.current.push(updater);\n }\n return [value, setFrameValue];\n}"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,MAAM,Q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