Browse Source

Bring back SafeAreaContext for better compat with 0.x

Janic Duplessis 4 years ago
parent
commit
7a7935f78b
1 changed files with 14 additions and 9 deletions
  1. 14
    9
      src/SafeAreaContext.tsx

+ 14
- 9
src/SafeAreaContext.tsx View File

@@ -91,6 +91,16 @@ export function useSafeAreaFrame(): Rect {
91 91
   return frame;
92 92
 }
93 93
 
94
+export function withSafeAreaInsets<T>(
95
+  WrappedComponent: React.ComponentType<T>,
96
+) {
97
+  return (props: T) => (
98
+    <SafeAreaConsumer>
99
+      {(insets) => <WrappedComponent {...props} insets={insets} />}
100
+    </SafeAreaConsumer>
101
+  );
102
+}
103
+
94 104
 /**
95 105
  * @deprecated
96 106
  */
@@ -107,12 +117,7 @@ export function SafeAreaConsumer(
107 117
   return <SafeAreaInsetsContext.Consumer {...props} />;
108 118
 }
109 119
 
110
-export function withSafeAreaInsets<T>(
111
-  WrappedComponent: React.ComponentType<T>,
112
-) {
113
-  return (props: T) => (
114
-    <SafeAreaConsumer>
115
-      {(insets) => <WrappedComponent {...props} insets={insets} />}
116
-    </SafeAreaConsumer>
117
-  );
118
-}
120
+/**
121
+ * @deprecated
122
+ */
123
+export const SafeAreaContext = SafeAreaInsetsContext;