Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
@react-navigation/native
Advanced tools
@react-navigation/native is a popular library for handling navigation in React Native applications. It provides a way to navigate between different screens and manage navigation state in a React Native app.
Stack Navigation
Stack Navigation allows you to navigate between different screens in a stack-like manner, where each new screen is placed on top of the previous one.
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
function HomeScreen() {
return (
<View>
<Text>Home Screen</Text>
</View>
);
}
function DetailsScreen() {
return (
<View>
<Text>Details Screen</Text>
</View>
);
}
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName="Home">
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Details" component={DetailsScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
Tab Navigation
Tab Navigation allows you to navigate between different screens using tabs at the bottom of the screen.
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
const Tab = createBottomTabNavigator();
function HomeScreen() {
return (
<View>
<Text>Home Screen</Text>
</View>
);
}
function SettingsScreen() {
return (
<View>
<Text>Settings Screen</Text>
</View>
);
}
export default function App() {
return (
<NavigationContainer>
<Tab.Navigator>
<Tab.Screen name="Home" component={HomeScreen} />
<Tab.Screen name="Settings" component={SettingsScreen} />
</Tab.Navigator>
</NavigationContainer>
);
}
Drawer Navigation
Drawer Navigation allows you to navigate between different screens using a drawer that slides in from the side of the screen.
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createDrawerNavigator } from '@react-navigation/drawer';
const Drawer = createDrawerNavigator();
function HomeScreen() {
return (
<View>
<Text>Home Screen</Text>
</View>
);
}
function NotificationsScreen() {
return (
<View>
<Text>Notifications Screen</Text>
</View>
);
}
export default function App() {
return (
<NavigationContainer>
<Drawer.Navigator initialRouteName="Home">
<Drawer.Screen name="Home" component={HomeScreen} />
<Drawer.Screen name="Notifications" component={NotificationsScreen} />
</Drawer.Navigator>
</NavigationContainer>
);
}
react-native-navigation is another popular navigation library for React Native. It provides a more native experience by using native navigation components. It is more complex to set up compared to @react-navigation/native but offers better performance and native look and feel.
react-router-native is a version of the popular React Router library adapted for React Native. It provides a similar API to React Router for web, making it easier for developers who are already familiar with React Router to use it in React Native applications. However, it lacks some of the advanced features and flexibility of @react-navigation/native.
@react-navigation/native
React Native integration for React Navigation.
Documentation can be found on the React Navigation website.
Open a Terminal in your project's folder and run,
yarn add @react-navigation/native
const ref = React.useRef();
useBackButton(ref);
const { getInitialState } = useLinking(ref, {
prefixes: ['https://myapp.com', 'myapp://'],
});
const [isReady, setIsReady] = React.useState(false);
const [initialState, setInitialState] = React.useState();
React.useEffect(() => {
getInitialState()
.catch(() => {})
.then(state => {
if (state !== undefined) {
setInitialState(state);
}
setIsReady(true);
});
}, [getInitialState]);
if (!isReady) {
return null;
}
return (
<NavigationContainer initialState={initialState} ref={ref}>
{/* content */}
</NavigationContainer>
);
FAQs
React Native integration for React Navigation
The npm package @react-navigation/native receives a total of 1,097,064 weekly downloads. As such, @react-navigation/native popularity was classified as popular.
We found that @react-navigation/native 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.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.