Socket
Socket
Sign inDemoInstall

react-native-screens

Package Overview
Dependencies
Maintainers
5
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-screens

Native navigation primitives for your React Native app.


Version published
Weekly downloads
1.1M
increased by8.76%
Maintainers
5
Weekly downloads
 
Created

What is react-native-screens?

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.

What are react-native-screens's main functionalities?

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;

Other packages similar to react-native-screens

FAQs

Package last updated on 14 Oct 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc