Browse Source

Bring back SafeAreaConsumer with deprecation warning

It is used in react-nav so let's make the transition easier
Janic Duplessis 4 years ago
parent
commit
fdb7c0accf
1 changed files with 17 additions and 1 deletions
  1. 17
    1
      src/SafeAreaContext.tsx

+ 17
- 1
src/SafeAreaContext.tsx View File

@@ -80,6 +80,22 @@ export function useSafeAreaFrame(): Rect {
80 80
  * @deprecated
81 81
  */
82 82
 export function useSafeArea(): EdgeInsets {
83
-  console.warn('useSafeArea is deprecated, use useSafeAreaInsets instead.');
83
+  React.useEffect(() => {
84
+    console.warn('useSafeArea is deprecated, use useSafeAreaInsets instead.');
85
+  }, []);
84 86
   return useSafeAreaInsets();
85 87
 }
88
+
89
+/**
90
+ * @deprecated
91
+ */
92
+export function SafeAreaConsumer(
93
+  props: React.ComponentProps<typeof SafeAreaInsetsContext.Consumer>,
94
+) {
95
+  React.useEffect(() => {
96
+    console.warn(
97
+      'SafeAreaConsumer is deprecated, use SafeAreaInsetsContext.Consumer instead.',
98
+    );
99
+  }, []);
100
+  return <SafeAreaInsetsContext.Consumer {...props} />;
101
+}