GT2/Ejectable/node_modules/@react-navigation/bottom-tabs/lib/commonjs/utils/useWindowDimensions.js.map

1 line
2.3 KiB
Plaintext
Raw Normal View History

2021-08-16 00:14:59 +00:00
{"version":3,"sources":["useWindowDimensions.tsx"],"names":["useWindowDimensions","dimensions","setDimensions","React","useState","height","width","Dimensions","get","useEffect","onChange","window","d","addEventListener","removeEventListener"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEA;AACA;AACe,SAASA,mBAAT,GAA+B;AAC5C,QAAM,CAACC,UAAD,EAAaC,aAAb,IAA8BC,KAAK,CAACC,QAAN,CAAe,MAAM;AACvD;AACA,UAAM;AAAEC,MAAAA,MAAM,GAAG,CAAX;AAAcC,MAAAA,KAAK,GAAG;AAAtB,QAA4BC,wBAAWC,GAAX,CAAe,QAAf,CAAlC;;AAEA,WAAO;AAAEH,MAAAA,MAAF;AAAUC,MAAAA;AAAV,KAAP;AACD,GALmC,CAApC;AAOAH,EAAAA,KAAK,CAACM,SAAN,CAAgB,MAAM;AACpB,UAAMC,QAAQ,GAAG,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAwC;AACvD,YAAM;AAAEL,QAAAA,KAAF;AAASD,QAAAA;AAAT,UAAoBM,MAA1B;AAEAT,MAAAA,aAAa,CAAEU,CAAD,IAAO;AACnB,YAAIN,KAAK,KAAKM,CAAC,CAACN,KAAZ,IAAqBD,MAAM,KAAKO,CAAC,CAACP,MAAtC,EAA8C;AAC5C,iBAAOO,CAAP;AACD;;AAED,eAAO;AAAEN,UAAAA,KAAF;AAASD,UAAAA;AAAT,SAAP;AACD,OANY,CAAb;AAOD,KAVD,CADoB,CAapB;AACA;;;AACAK,IAAAA,QAAQ,CAAC;AAAEC,MAAAA,MAAM,EAAEJ,wBAAWC,GAAX,CAAe,QAAf;AAAV,KAAD,CAAR;;AAEAD,4BAAWM,gBAAX,CAA4B,QAA5B,EAAsCH,QAAtC;;AAEA,WAAO,MAAMH,wBAAWO,mBAAX,CAA+B,QAA/B,EAAyCJ,QAAzC,CAAb;AACD,GApBD,EAoBG,EApBH;AAsBA,SAAOT,UAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { ScaledSize, Dimensions } from 'react-native';\n\n// This is similar to the new useWindowDimensions hook in react-native\n// However, we have a custom implementation to support older RN versions\nexport default function useWindowDimensions() {\n const [dimensions, setDimensions] = React.useState(() => {\n // `height` and `width` maybe undefined during SSR, so we initialize them\n const { height = 0, width = 0 } = Dimensions.get('window');\n\n return { height, width };\n });\n\n React.useEffect(() => {\n const onChange = ({ window }: { window: ScaledSize }) => {\n const { width, height } = window;\n\n setDimensions((d) => {\n if (width === d.width && height === d.height) {\n return d;\n }\n\n return { width, height };\n });\n };\n\n // We might have missed an update before the listener was added\n // So make sure to update the dimensions\n onChange({ window: Dimensions.get('window') });\n\n Dimensions.addEventListener('change', onChange);\n\n return () => Dimensions.removeEventListener('change', onChange);\n }, []);\n\n return dimensions;\n}\n"]}