a295d043aa01e3978d33d9ea75c2127598a1955fbfe45a8dceb39cf520425088.json 3.6 KB

1
  1. {"ast":null,"code":"import * as React from 'react';\nimport raf from \"rc-util/es/raf\";\nexport default function useFrameState(defaultValue) {\n const [value, setValue] = React.useState(defaultValue);\n const frameRef = React.useRef(null);\n const batchRef = React.useRef([]);\n const destroyRef = React.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","raf","useFrameState","defaultValue","value","setValue","useState","frameRef","useRef","batchRef","destroyRef","useEffect","current","cancel","setFrameValue","updater","prevValue","forEach","func","push"],"sources":["/Users/max_liu/max_liu/company/tools_auto_pt/node_modules/antd/es/form/hooks/useFrameState.js"],"sourcesContent":["import * as React from 'react';\nimport raf from \"rc-util/es/raf\";\nexport default function useFrameState(defaultValue) {\n const [value, setValue] = React.useState(defaultValue);\n const frameRef = React.useRef(null);\n const batchRef = React.useRef([]);\n const destroyRef = React.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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