Gathering detailed insights and metrics for react-native-safe-area
Gathering detailed insights and metrics for react-native-safe-area
Gathering detailed insights and metrics for react-native-safe-area
Gathering detailed insights and metrics for react-native-safe-area
npm install react-native-safe-area
85
Supply Chain
99
Quality
75.9
Maintenance
100
Vulnerability
100
License
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
113 Stars
82 Commits
23 Forks
3 Watching
16 Branches
8 Contributors
Updated on 17 Jan 2023
JavaScript (61.55%)
Objective-C (34.42%)
Ruby (4.04%)
Cumulative downloads
Total Downloads
Last day
58.6%
1,784
Compared to previous day
Last week
4.5%
6,870
Compared to previous week
Last month
37.9%
27,064
Compared to previous month
Last year
-18.6%
296,712
Compared to previous year
React Native module to handle safe area insets natively for iOS 11 or later.
npm
1npm install --save react-native-safe-area
You can link native code in the way you prefer:
Add line to your project target section in your Podfile:
1target 'YourProjectTarget' do 2 3+ pod 'react-native-safe-area', path: '../node_modules/react-native-safe-area' 4 5end
If you received error jest-haste-map: Haste module naming collision: Duplicate module name: react-native
, add lines below to your Podfile and reinstall pods.
1target 'YourProjectTarget' do 2 3+ rn_path = '../node_modules/react-native' 4+ pod 'yoga', path: "#{rn_path}/ReactCommon/yoga/yoga.podspec" 5+ pod 'React', path: rn_path 6 7 pod 'react-native-safe-area', path: '../node_modules/react-native-safe-area' 8 9end 10 11+ post_install do |installer| 12+ installer.pods_project.targets.each do |target| 13+ if target.name == "React" 14+ target.remove_from_project 15+ end 16+ end 17+ end
Run command below:
1react-native link react-native-safe-area
Use withSafeArea
to apply safe area insets to views automatically.
1import { withSafeArea } from 'react-native-safe-area'
A higher-order component which applies safe area insets automatically to the wrapped component.
component
: Component - Wrapped component.applyTo
: string - (Optional) Specify property to apply safe area insets.
margin
- style.margin
. (Default)padding
- style.padding
.absolutePosition
- style.top
, style.bottom
, style.left
and style.right
.contentInset
- contentInset
and contentOffset
for scroll views.direction
: string - (Optional) Specify direction to apply safe area insets.
top
- Apply to top.bottom
- Apply to bottom.left
- Apply to left.right
- Apply to right.topAndLeft
- top
+ left
.topAndRight
- top
+ right
.bottomAndLeft
- bottom
+ left
.bottomAndRight
- bottom
+ right
.horizontal
- left
+ right
.horizontalAndTop
- horizontal
+ top
.horizontalAndBottom
- horizontal
+ bottom
.vertical
- top
+ bottom
.verticalAndLeft
- vertical
+ left
.verticalAndRight
- vertical
+ right
.all
- horizontal
+ vertical
. (Default)1const SafeAreaView = withSafeArea(View, 'margin', 'all') 2 3class App extends Component<{}> { 4 render() { 5 return ( 6 <SafeAreaView> 7 <View /> 8 </SafeAreaView> 9 ) 10 } 11}
1const SafeAreaScrollView = withSafeArea(ScrollView, 'contentInset', 'vertical') 2 3class App extends Component<{}> { 4 render() { 5 return ( 6 <SafeAreaScrollView> 7 <View /> 8 </SafeAreaScrollView> 9 ) 10 } 11}
You can also apply safe area insets to FlatList and SectionList.
wrappedRef
: refReturns wrapped component's ref.
currentSafeAreaInsets
: SafeAreaInsetsReturns current safe area insets.
1import SafeArea from 'react-native-safe-area'
If you want to use SafeAreaInsets
type, you can import it like below:
1import SafeArea, { type SafeAreaInsets } from 'react-native-safe-area'
1SafeArea.getSafeAreaInsetsForRootView() 2 .then((result) => { 3 console.log(result) 4 // { safeAreaInsets: { top: 44, left: 0, bottom: 34, right: 0 } } 5 })
1class App extends Component<{}> { 2 // To keep the context of 'this' 3 onSafeAreaInsetsForRootViewChange = this.onSafeAreaInsetsForRootViewChange.bind(this) 4 5 componentDidMount() { 6 // Add event listener 7 SafeArea.addEventListener('safeAreaInsetsForRootViewDidChange', this.onSafeAreaInsetsForRootViewChange) 8 } 9 10 componentWillUnmount() { 11 // Remove event listener 12 SafeArea.removeEventListener('safeAreaInsetsForRootViewDidChange', this.onSafeAreaInsetsForRootViewChange) 13 } 14 15 onSafeAreaInsetsForRootViewChange(result) { 16 // Called every time that safe area insets changed 17 console.log(result) 18 // { safeAreaInsets: { top: 0, left: 44, bottom: 21, right: 44 } } 19 } 20}
A simple example project is here.
No vulnerabilities found.
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 5/23 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
92 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More