|
@@ -96,10 +96,10 @@ function App() {
|
96
|
96
|
Usage with hooks api:
|
97
|
97
|
|
98
|
98
|
```js
|
99
|
|
-import { useSafeArea } from 'react-native-safe-area-context';
|
|
99
|
+import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
100
|
100
|
|
101
|
101
|
function HookComponent() {
|
102
|
|
- const insets = useSafeArea();
|
|
102
|
+ const insets = useSafeAreaInsets();
|
103
|
103
|
|
104
|
104
|
return <View style={{ paddingTop: insets.top }} />;
|
105
|
105
|
}
|
|
@@ -108,14 +108,14 @@ function HookComponent() {
|
108
|
108
|
Usage with consumer api:
|
109
|
109
|
|
110
|
110
|
```js
|
111
|
|
-import { SafeAreaConsumer } from 'react-native-safe-area-context';
|
|
111
|
+import { SafeAreaInsetsContext } from 'react-native-safe-area-context';
|
112
|
112
|
|
113
|
113
|
class ClassComponent extends React.Component {
|
114
|
114
|
render() {
|
115
|
115
|
return (
|
116
|
|
- <SafeAreaConsumer>
|
|
116
|
+ <SafeAreaInsetsContext.Consumer>
|
117
|
117
|
{insets => <View style={{ paddingTop: insets.top }} />}
|
118
|
|
- </SafeAreaConsumer>
|
|
118
|
+ </SafeAreaInsetsContext.Consumer>
|
119
|
119
|
);
|
120
|
120
|
}
|
121
|
121
|
}
|
|
@@ -137,21 +137,21 @@ function SomeComponent() {
|
137
|
137
|
|
138
|
138
|
### Web SSR
|
139
|
139
|
|
140
|
|
-If you are doing server side rendering on the web you can use `initialSafeAreaInsets` to inject insets value based on the device the user has, or simply pass zero values. Since insets measurement is async it will break rendering your page content otherwise.
|
|
140
|
+If you are doing server side rendering on the web you can use `initialMetrics` to inject insets and frame value based on the device the user has, or simply pass zero values. Since insets measurement is async it will break rendering your page content otherwise.
|
141
|
141
|
|
142
|
142
|
### Optimization
|
143
|
143
|
|
144
|
|
-To speed up the initial render, you can import `initialWindowSafeAreaInsets` from this package and set as the `initialSafeAreaInsets` prop on the provider as described in Web SSR. You cannot do this if your provider remounts, or you are using `react-native-navigation`.
|
|
144
|
+To speed up the initial render, you can import `initialWindowMetrics` from this package and set as the `initialMetrics` prop on the provider as described in Web SSR. You cannot do this if your provider remounts, or you are using `react-native-navigation`.
|
145
|
145
|
|
146
|
146
|
```js
|
147
|
147
|
import {
|
148
|
148
|
SafeAreaProvider,
|
149
|
|
- initialWindowSafeAreaInsets
|
|
149
|
+ initialWindowMetrics
|
150
|
150
|
} from 'react-native-safe-area-context';
|
151
|
151
|
|
152
|
152
|
function App() {
|
153
|
153
|
return (
|
154
|
|
- <SafeAreaProvider initialSafeAreaInsets={initialWindowSafeAreaInsets}>
|
|
154
|
+ <SafeAreaProvider initialMetrics={initialWindowMetrics}>
|
155
|
155
|
...
|
156
|
156
|
</SafeAreaProvider>
|
157
|
157
|
);
|