Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
react-native-screens
Advanced tools
First incomplete navigation solution for your react-native app.
The react-native-screens package provides native primitives to manage and optimize navigation and screen transitions in React Native applications. It aims to improve performance by using native navigation components.
Native Stack Navigator
This feature allows you to create a stack navigator using native components, which can improve performance and provide a more seamless user experience.
import { createNativeStackNavigator } from 'react-native-screens/native-stack';
import { NavigationContainer } from '@react-navigation/native';
import HomeScreen from './HomeScreen';
import DetailsScreen from './DetailsScreen';
const Stack = createNativeStackNavigator();
function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Details" component={DetailsScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;
Screen Component
The Screen and ScreenContainer components allow you to manage screens more efficiently by leveraging native screen management, which can lead to better performance.
import { Screen, ScreenContainer } from 'react-native-screens';
import { View, Text } from 'react-native';
function MyScreen() {
return (
<Screen>
<View>
<Text>My Screen Content</Text>
</View>
</Screen>
);
}
function App() {
return (
<ScreenContainer>
<MyScreen />
</ScreenContainer>
);
}
export default App;
Screen Lifecycle Methods
This feature allows you to use lifecycle methods to detect when a screen is focused or unfocused, enabling you to perform actions like data fetching or cleanup.
import { useFocusEffect } from '@react-navigation/native';
import { useCallback } from 'react';
import { View, Text } from 'react-native';
function MyScreen() {
useFocusEffect(
useCallback(() => {
console.log('Screen is focused');
return () => {
console.log('Screen is unfocused');
};
}, [])
);
return (
<View>
<Text>My Screen Content</Text>
</View>
);
}
export default MyScreen;
React Navigation is a popular library for routing and navigation in React Native applications. It provides a wide range of navigators, including stack, tab, and drawer navigators. While react-native-screens focuses on optimizing performance with native components, React Navigation offers a more comprehensive set of features and is highly customizable.
React Native Navigation by Wix is another powerful navigation library that provides native navigation components. It offers a more native feel and performance compared to React Navigation but can be more complex to set up. It is similar to react-native-screens in its focus on native performance but provides a more extensive set of features.
First incomplete navigation solution for your React Native app
FAQs
Native navigation primitives for your React Native app.
The npm package react-native-screens receives a total of 902,095 weekly downloads. As such, react-native-screens popularity was classified as popular.
We found that react-native-screens demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 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.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.