diff --git a/packages/react-native-web/src/exports/SafeAreaView/index.js b/packages/react-native-web/src/exports/SafeAreaView/index.js index d42c1c03..90f9af40 100644 --- a/packages/react-native-web/src/exports/SafeAreaView/index.js +++ b/packages/react-native-web/src/exports/SafeAreaView/index.js @@ -9,13 +9,26 @@ */ import type { ViewProps } from '../View'; +import type { Node } from 'react'; import { canUseDOM } from 'fbjs/lib/ExecutionEnvironment'; -import React from 'react'; import StyleSheet from '../StyleSheet'; import View from '../View'; +import React, { forwardRef } from 'react'; -const SafeAreaView = React.forwardRef((props: ViewProps, ref) => { +const cssFunction: 'constant' | 'env' = (function() { + if ( + canUseDOM && + window.CSS && + window.CSS.supports && + window.CSS.supports('top: constant(safe-area-inset-top)') + ) { + return 'constant'; + } + return 'env'; +})(); + +const SafeAreaView = forwardRef((props, ref) => { const { style, ...rest } = props; return ( @@ -32,18 +45,6 @@ const SafeAreaView = React.forwardRef((props: ViewProps, ref) = SafeAreaView.displayName = 'SafeAreaView'; -const cssFunction: 'constant' | 'env' = (function() { - if ( - canUseDOM && - window.CSS && - window.CSS.supports && - window.CSS.supports('top: constant(safe-area-inset-top)') - ) { - return 'constant'; - } - return 'env'; -})(); - const styles = StyleSheet.create({ root: { paddingTop: `${cssFunction}(safe-area-inset-top)`,