You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Scripted/website/node_modules/.cache/babel-loader/c06e929bd0bff13710383996b94...

1 line
2.6 KiB

{"ast":null,"code":"import { useRef, useEffect } from 'react';\n/**\n * Track whether a component is current mounted. Generally less preferable than\n * properlly canceling effects so they don't run after a component is unmounted,\n * but helpful in cases where that isn't feasible, such as a `Promise` resolution.\n *\n * @returns a function that returns the current isMounted state of the component\n *\n * ```ts\n * const [data, setData] = useState(null)\n * const isMounted = useMounted()\n *\n * useEffect(() => {\n * fetchdata().then((newData) => {\n * if (isMounted()) {\n * setData(newData);\n * }\n * })\n * })\n * ```\n */\n\nexport default function useMounted() {\n var mounted = useRef(true);\n var isMounted = useRef(function () {\n return mounted.current;\n });\n useEffect(function () {\n mounted.current = true;\n return function () {\n mounted.current = false;\n };\n }, []);\n return isMounted.current;\n}","map":{"version":3,"names":["useRef","useEffect","useMounted","mounted","isMounted","current"],"sources":["C:/Cours/SAE/SAE-3.01/Scripted/Scripted/website/node_modules/@restart/hooks/esm/useMounted.js"],"sourcesContent":["import { useRef, useEffect } from 'react';\n/**\n * Track whether a component is current mounted. Generally less preferable than\n * properlly canceling effects so they don't run after a component is unmounted,\n * but helpful in cases where that isn't feasible, such as a `Promise` resolution.\n *\n * @returns a function that returns the current isMounted state of the component\n *\n * ```ts\n * const [data, setData] = useState(null)\n * const isMounted = useMounted()\n *\n * useEffect(() => {\n * fetchdata().then((newData) => {\n * if (isMounted()) {\n * setData(newData);\n * }\n * })\n * })\n * ```\n */\n\nexport default function useMounted() {\n var mounted = useRef(true);\n var isMounted = useRef(function () {\n return mounted.current;\n });\n useEffect(function () {\n mounted.current = true;\n return function () {\n mounted.current = false;\n };\n }, []);\n return isMounted.current;\n}"],"mappings":"AAAA,SAASA,MAAM,EAAEC,SAAS,QAAQ,OAAO;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,eAAe,SAASC,UAAU,GAAG;EACnC,IAAIC,OAAO,GAAGH,MAAM,CAAC,IAAI,CAAC;EAC1B,IAAII,SAAS,GAAGJ,MAAM,CAAC,YAAY;IACjC,OAAOG,OAAO,CAACE,OAAO;EACxB,CAAC,CAAC;EACFJ,SAAS,CAAC,YAAY;IACpBE,OAAO,CAACE,OAAO,GAAG,IAAI;IACtB,OAAO,YAAY;MACjBF,OAAO,CAACE,OAAO,GAAG,KAAK;IACzB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EACN,OAAOD,SAAS,CAACC,OAAO;AAC1B"},"metadata":{},"sourceType":"module"}