react-native-easy-navigation
Simple and fast navigation for react-native
Note: Needs
react-native-reanimated
andreact-native-gesture-handler
!
Table of Contents
Why this instead of react-navigation or wix-navigation?
Well, in most cases I guess the best option this to choose one of above but I created this lib so I could create apps faster with less worry about the navigation part.
This lib is super flexible. The only required component to use is NavigationProvider
. The rest is just there for getting started faster.
Features
- Supports left-to-right transitions for ios and android
- Same transitions on both ios and android
- Drawer support
- Tabs support
- Supports push, replace and pop screens
- Regular screens
- Half panels
- Modals
- Layovers
Installation
Follow the instructions how to install react-native-gesture-handler
and react-native-reanimated
. Nothing else is required. Read Usage to get started using the navigation.
Usage
const Home = const router = return <Screen ="Home"> <Button = ="Go to Article 1"/> <Button = ="Go to Article 2"/> </Screen> const Profile = const router = return <Screen ="Profile"> <Button = ="Open modal"/> <Button = ="Open half panel"/> </Screen> const Article = title id const router = return <Screen => <Text>Fetch article with ID = id</Text> <Button = ="Custom go back button"/> <Button = ="Replace with Article 3"/> <Button = ="Push with Article 4"/> <Button = ="Push with Article 4"/> </Screen> const Modal = text type return <Screen => <Text>text</Text> </Screen> const Drawer = text type return <View => <Text>My drawer</Text> </View> const App = return <NavigationProvider ="Home" = = = />
Components
NavigationProvider
<NavigationProvider = = // // =>
Screen
You can wrap all your main views with the Screen
component. This component will add a header with a title and a back button (if you are deeper then the first screen).
const Home = <Screen ="Home"> /* rest of your view */ </Screen>
Hooks
useScreen
This is help full to get information from the screen you are at.
const Home = const showBackButton screen: id name mode animated statusBar: barStyle header: backgroundColor color = return null}
useRouter
If you want to navigate this is the hook!
const Home = const push pop replace reset // and all the shortcuts you defined in <NavigationProvider router={} /> navigateToArticle = return <> <Button ="Push" = /> <Button ="Shortcut" = /> </> }