
Security News
Node.js Moves Toward Stable TypeScript Support with Amaro 1.0
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
react-native-safe-area-view
Advanced tools
Add padding to your views to account for notches, home indicators, status bar, and possibly other future things.
This library provides automatic padding when a view intersects with a safe area (notch, status bar, home indicator).
expo install react-native-safe-area-view react-native-safe-area-context
yarn add react-native-safe-area-view react-native-safe-area-context
Next, you need to link react-native-safe-area-context
. If you are using autolinking, run pod install
again. If not, follow these instructions. Then re-build your app binary.
First you need to wrap the root of your app with the SafeAreaProvider
.
import * as React from 'react';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import MyAwesomeApp from './src/MyAwesomeApp';
export default function App() {
return (
<SafeAreaProvider>
<MyAwesomeApp />
</SafeAreaProvider>
);
}
Now you can wrap components that touch any edge of the screen with a SafeAreaView
.
import SafeAreaView from 'react-native-safe-area-view';
export default function MyAwesomeApp() {
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={{ flex: 1 }}>
<Text>
Look, I'm safe! Not under a status bar or notch or home indicator or
anything! Very cool
</Text>
</View>
</SafeAreaView>
);
}
Sometimes you will observe unexpected behavior and jank because SafeAreaView uses onLayout
then calls measureInWindow
on the view. If you know your view will touch certain edges, use forceInset
to force it to apply the inset padding on the view.
<SafeAreaView forceInset={{ top: 'always' }}>
<View>
<Text>Yeah, I'm safe too!</Text>
</View>
</SafeAreaView>
forceInset
takes an object with the keys top | bottom | left | right | vertical | horizontal
and the values 'always' | 'never'
. Or you can override the padding altogether by passing an integer.
Sometimes it's useful to know what the insets are for the top, right, bottom, and left of the screen. See the documentation for react-native-safe-area-context for more information.
FAQs
Add padding to your views to account for notches, home indicators, status bar, and possibly other future things.
The npm package react-native-safe-area-view receives a total of 78,797 weekly downloads. As such, react-native-safe-area-view popularity was classified as popular.
We found that react-native-safe-area-view demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Amaro 1.0 lays the groundwork for stable TypeScript support in Node.js, bringing official .ts loading closer to reality.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.