Gathering detailed insights and metrics for react-native-screens
Gathering detailed insights and metrics for react-native-screens
Gathering detailed insights and metrics for react-native-screens
Gathering detailed insights and metrics for react-native-screens
@react-navigation/native-stack
Native stack navigator using react-native-screens
@exodus/react-navigation-native-stack
Native stack navigator using react-native-screens
@embrace-io/react-navigation
This is used to track React Native screens with the Embrace SDK
@react-native-embrace/react-navigation
This is used to track React Native screens with Embrace SDK
Native navigation primitives for your React Native app.
npm install react-native-screens
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
3,108 Stars
1,220 Commits
521 Forks
43 Watching
153 Branches
166 Contributors
Updated on 27 Nov 2024
TypeScript (40.9%)
Kotlin (21.24%)
Objective-C++ (21%)
C++ (6%)
JavaScript (5.32%)
Objective-C (2.32%)
Java (2.06%)
Ruby (0.44%)
C (0.4%)
CMake (0.28%)
Starlark (0.01%)
Shell (0.01%)
Cumulative downloads
Total Downloads
Last day
-6.5%
234,073
Compared to previous day
Last week
1%
1,268,098
Compared to previous week
Last month
12%
5,177,709
Compared to previous month
Last year
41.7%
49,486,072
Compared to previous year
2
2
40
This project aims to expose native navigation container components to React Native. It is not designed to be used as a standalone library but rather as a dependency of a full-featured navigation library.
To learn about how to use react-native-screens
with Fabric architecture, head over to Fabric README. Instructions on how to run Fabric Example within this repo can be found in the FabricExample README.
Installation on iOS is completely handled with auto-linking, if you have ensured pods are installed after adding this module, no other actions are necessary.
On Android the View state is not persisted consistently across Activity restarts, which can lead to crashes in those cases. It is recommended to override the native Android method called on Activity restarts in your main Activity, to avoid these crashes.
For most people using an app built from the react-native template, that means editing MainActivity.java
, likely located in android/app/src/main/java/<your package name>/MainActivity.java
You should add this code, which specifically discards any Activity state persisted during the Activity restart process, to avoid inconsistencies that lead to crashes.
Please note that the override code should not be placed inside MainActivityDelegate
, but rather directly in MainActivity
.
1import android.os.Bundle; 2 3public class MainActivity extends ReactActivity { 4 5 //...code 6 7 //react-native-screens override 8 @Override 9 protected void onCreate(Bundle savedInstanceState) { 10 super.onCreate(null); 11 } 12 13 public static class MainActivityDelegate extends ReactActivityDelegate { 14 //...code 15 } 16}
1import android.os.Bundle; 2 3class MainActivity: ReactActivity() { 4 5 //...code 6 7 //react-native-screens override 8 override fun onCreate(savedInstanceState: Bundle?) { 9 super.onCreate(null); 10 } 11}
For people that must handle cases like this, there is a more detailed discussion of the difficulties in a series of related comments.
Since v3.6.0
react-native-screens
has been rewritten with Kotlin. Kotlin version used in this library defaults to 1.4.10
.
If you need to use a different Kotlin version, set kotlinVersion
ext property in your project's android/build.gradle
and the library will use this version accordingly:
buildscript {
ext {
...
kotlinVersion = "1.4.10"
}
}
Disclaimer: react-native-screens
requires Kotlin 1.3.50
or higher.
Installation on Windows should be completely handled with auto-linking when using React Native Windows 0.63+. For earlier versions, you must manually link the native module.
Screens are already integrated with the React Native's most popular navigation library react-navigation and Expo.
Paper is the default rendering system for React Native versions prior to 0.76.
library version | react-native version |
---|---|
3.33.0+ | 0.72.0+ |
3.32.0+ | 0.71.0+ |
3.30.0+ | 0.68.0+ |
3.14.0+ | 0.64.0+ |
3.0.0+ | 0.62.0+ |
2.0.0+ | 0.60.0+ |
Fabric is React Native's new rendering system.
Here's a table with summary of supported react-native
versions when Fabric is turned on.
library version | react-native version |
---|---|
3.35.0+ | 0.76.0+ |
3.33.0+ | 0.75.0+ |
3.32.0+ | 0.74.0+ |
3.28.0+ | 0.73.0+ |
3.21.0+ | 0.72.0+ |
3.19.0+ | 0.71.0+ |
3.18.0+ | 0.70.0+ |
3.14.0+ | 0.69.0+ |
[!CAUTION] JS API of the native stack has been moved from
react-native-screens/native-stack
to@react-navigation/native-stack
since version v6. Currently, native stack v5 (imported fromreact-native-screens/native-stack
) is deprecated and will be removed in the upcoming minor release.react-native-screens
v4 will support only@react-navigation/native-stack
v7.
Screens support is built into react-navigation starting from version 2.14.0 for all the different navigator types (stack, tab, drawer, etc).
To configure react-navigation to use screens instead of plain RN Views for rendering screen views, simply add this library as a dependency to your project:
1# bare React Native project 2yarn add react-native-screens 3 4# if you use Expo managed workflow 5npx expo install react-native-screens
Just make sure that the version of react-navigation you are using is 2.14.0 or higher.
You are all set 🎉 – when screens are enabled in your application code react-navigation will automatically use them instead of relying on plain React Native Views.
react-freeze
You have to use React Native 0.68 or higher, react-navigation 5.x or 6.x and react-native-screens >= v3.9.0
Since v3.9.0
, react-native-screens
comes with experimental support for react-freeze
. It uses the React Suspense
mechanism to prevent parts of the React component tree from rendering, while keeping its state untouched.
To benefit from this feature, enable it in your entry file (e.g. App.js
) with this snippet:
1import { enableFreeze } from 'react-native-screens'; 2 3enableFreeze(true);
Want to know more? Check out react-freeze README
Found a bug? File an issue here or directly in react-freeze repository.
react-native-screens
If, for whatever reason, you'd like to disable native screens support and use plain React Native Views add the following code in your entry file (e.g. App.js
):
1import { enableScreens } from 'react-native-screens'; 2 3enableScreens(false);
You can also disable the usage of native screens per navigator with detachInactiveScreens
.
createNativeStackNavigator
with React NavigationTo take advantage of the native stack navigator primitive for React Navigation that leverages UINavigationController
on iOS and Fragment
on Android, please refer:
FullWindowOverlay
Native iOS
component for rendering views straight under the Window
. Based on RCTPerfMonitor
. You should treat it as a wrapper, providing full-screen, transparent view which receives no props and should ideally render one child View
, being the root of its view hierarchy. For the example usage, see https://github.com/software-mansion/react-native-screens/blob/main/apps/src/tests/Test1096.tsx
React-native-navigation library already uses native containers for rendering navigation scenes so wrapping these scenes with <ScreenContainer>
or <Screen>
component does not provide any benefits. Yet if you would like to build a component that uses screens primitives under the hood (for example a view pager component) it is safe to use <ScreenContainer>
and <Screen>
components for that as these work out of the box when rendered on react-native-navigation scenes.
This library should work out of the box with all existing react-native libraries. If you experience problems with interoperability please report an issue.
If you are building a navigation library you may want to use react-native-screens
to have control over which parts of the React component tree are attached to the native view hierarchy.
To do that, react-native-screens
provides you with the components documented here.
Use ScrollView
with prop contentInsetAdjustmentBehavior=“automatic”
as a main container of the screen and set headerTranslucent: true
in screen options.
There are many ways to contribute to this project. See CONTRIBUTING guide for more information. Thank you for your interest in contributing!
React native screens library is licensed under The MIT License.
This project has been build and is maintained thanks to the support from Shopify, Expo.io, and Software Mansion.
Since 2012 Software Mansion is a software agency with experience in building web and mobile apps. We are Core React Native Contributors and experts in dealing with all kinds of React Native issues. We can help you build your next dream product – Hire us.
No vulnerabilities found.
Reason
30 commit(s) and 23 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
Found 10/29 approved changesets -- score normalized to 3
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
19 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