react-native-examples
# React Native Examples [](https://github.com/expo/expo) [](https://github.com/expo/expo) [](https://twitter.com/amanhimself) ## Why react-native-examples I am passionate about React Native and Expo ecosystem and one thing I often struggled with is the lack of resources when I was getting started. My another passion is for writing and I though why not combine these two and see how it goes. I write about React Native and Expo form of blog posts, and tutorials on my personal blog [**amanhimself.dev**](https://amanhimself.dev/) and sometimes for [other external publications such as LogRocket, freeCodeCamp, Sentry, and Jscrambler](https://amanhimself.dev/about/). This repository is a collection of examples created for those blog posts. With time, it gets harder to maintain different repositories, update the code and dependencies (and trying to match up with the speed of ever-changing ecosystem). Thus, I decided to keep all of projects/exmaples that are mostly code examples used in these various tutorials in one place and hence, this repository. It's completely [free](https://github.com/amandeepmittal/react-native-examples/blob/main/LICENSE.md). If you find anything useful in this repo, go ahead pick up any code snippet, use it in your own way. You may find some of the examples being outdated in time, in terms of framework updates or libraries. Don't worry the concept would be the same. Feel free top up an issue or a PR if you feel like somethings needs to be changed. **To keep me caffeinated, you can buy me a coffee too βοΈ** [](https://github.com/sponsors/amandeepmittal?frequency=one-time) --- ## Add opacity to Pressable component - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/main/pressable-with-opacity) - π [Blog post](https://amanhimself.dev/blog/add-opacity-to-pressable-component-react-native/) This example uses: - Expo SDK 53 <img src="https://i.imgur.com/LDyiXIu.gif" width="200"/> ## Remove Header Border Width in React Navigation or Expo Router - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/main/remove-header-border-react-navigation) - π [Blog post](https://amanhimself.dev/blog/remove-bottom-border-shadow-on-header-in-react-navigation/) This example uses: - Expo SDK 51 - [Expo Router v3](https://docs.expo.dev/router/introduction/) <img src="https://i.imgur.com/PnxIHxT.png" width="200"/> <img src="https://i.imgur.com/bBQuIJJ.png" width="200"/> ## Deep Linking with React Native and React Navigation v6 - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/main/rnDeepLinking) - π [Blog post](https://amanhimself.dev/blog/handle-deep-linking-react-native/) This example uses: - React Native `0.67.x` - [React Navigation v6](https://reactnavigation.org/) <img src="https://i.imgur.com/vinhEG4.gif" width="440"/> ## useInfiniteQuery hook from React Query and FlatList - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/main/infinite-scroll-with-react-query) - π [Blog post](https://amanhimself.dev/blog/infinite-scroll-with-react-query-and-flatlist-in-react-native/) This example uses: - Expo SDK `44` - [create-react-native-app](https://github.com/expo/create-react-native-app) - [NativeBase v3](https://docs.nativebase.io/installation) - [React Query](https://react-query.tanstack.com/) <img src="https://i.imgur.com/uLmbrjC.gif" width="200"/> ## Show/Hide Password Visibility Custom Hook - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/main/password-visibility-custom-hook-example) - π [Blog post](https://amanhimself.dev/blog/show-hide-password-in-react-native-using-custom-hook/) This example uses: - Expo SDK 51 <img src="https://i.imgur.com/rTNH2Ud.gif" width="200"/> ## Safe Area Context in React Native and Expo apps - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/safe-area-insets-example) - π [Blog post](https://amanhimself.dev/blog/safe-area-context-in-react-native-apps/) This example uses: - Expo SDK `44` - [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) <img src="https://i.imgur.com/86uwW7N.png" width="400"/> ## Add splash screen and app icon - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/rnSplashAndIconExample) - π [Blog post](https://amanhimself.dev/blog/how-to-add-a-splash-screen-and-app-icon-in-react-native-with-react-native-bootsplash/) This example uses: - React Native version `0.65.1` - React Navigation v6 - [react-native-bootsplash](https://github.com/zoontek/react-native-bootsplash) <img src="https://i.imgur.com/kJMWcH1.gif" width="400"/> ## Multi-language Support Example Learn how to add multi-language support to a React Native app using [i18next](https://www.i18next.com/). - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/rnMultiLanguageExample) - π [Blog post](https://amanhimself.dev/blog/multi-language-support-in-react-native-with-react-i18next/) This example uses: - React Native version `0.64.1` - React Navigation v6 - react-native-localize - i18next - react-i18next - @react-native-async-storage/async-storage ## Expo Firebase Auth Example Learn how to integrate Firebase Auth service using Firebase JS SDK and Expo SDK (by generating a managed workflow app). - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/expo-firebase-auth-example) - π [Blog post](https://amanhimself.dev/blog/firebase-authentication-with-expo/) This example uses: - Expo SDK version `41.x.x` - Firebase JS SDK - React Navigation version `5.x.x` - Managing Environment Variables with `app.config.json` ## Create a custom Image Gallery Preview Learn how to sync thumbnail using `FlatList` with Carousel from `react-native-snap-carousel`. - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/rnPreviewImageGallery) - π [Blog post](https://medium.com/crowdbotics/how-to-create-a-custom-image-gallery-in-react-native-b84b3c4906ec) This example uses: - React Native version `0.63.4` - The [scrollToOffset method on FlatList](https://reactnative.dev/docs/flatlist#scrolltooffset) - [react-native-snap-carousel](https://github.com/meliorence/react-native-snap-carousel) - Images from [Unsplash](https://unsplash.com/s/photos/amsterdam) <img src="https://i.imgur.com/z9MXxjA.png" width="200"/> <img src="https://i.imgur.com/5tYg6ss.gif" width="200"/> ## Convert Reverse Geocode into Postal Address Fetch user's current location and then convert into actual postal address. - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/expo-geolocation-example) - π [Blog post](https://amanhimself.dev/blog/react-native-geolocation-to-get-postal-address/) This example uses: - Expo SDK 44 - [React Navigation Stack v6](https://reactnavigation.org/docs/getting-started) - [expo-location](https://docs.expo.dev/versions/latest/sdk/location/) - Icon from [Flaticon.com](https://www.flaticon.com/free-icon/placeholder_1001022?term=location&related_id=1001022) <img src="https://i.imgur.com/YSBT6tv.gif" width="200"/> ## Create a Translucent Bottom Tab Bar - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/customTabBar) - π [Blog post](https://amanhimself.dev/blog/create-custom-tab-bar-in-react-native/) This example uses: - react-native-cli - [React Navigation Bottom Tabs v5](https://reactnavigation.org/docs/getting-started) - [BlurView](https://github.com/Kureev/react-native-blur) effect - Images from Unsplash <img src="https://i.imgur.com/Bp58Gzm.gif" width="200"/> <img src="https://i.imgur.com/O3oHRpd.gif" width="200"/> ## Shared Element transitions - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/shared-element-transitions) - π [Blog post](https://blog.logrocket.com/how-to-use-shared-element-transition-with-react-navigation-v5/) This example uses: - Expo SDK 44 - [React Navigation v6](https://reactnavigation.org/docs/getting-started) - [react-navigation-shared-element](https://github.com/IjzerenHein/react-navigation-shared-element) - [react-native-shared-element](https://github.com/IjzerenHein/react-native-shared-element#SharedElementAnimation) - Images from Unsplash - Delayed loading example using [react-native-animatable](https://github.com/oblador/react-native-animatable) <img src="https://i.imgur.com/M4Fhl05.gif" width="200"/> ## Custom scroll bar indicator in ScrollView with Animated API - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/custom-scroll-indicator) - π [Blog post](https://amanhimself.dev/blog/custom-scroll-bar-indicator-with-react-native-animated-api) - **Description**: The implementation of a scroll bar indicator is not directly customizable on cross-platforms in React Native. If you are building an app whose screen design depends on displaying a customized scroll bar indicator, then let's build one in this tutorial. This example uses: - Expo SDK 44 - `Animated.multiply()` from React Native API - `onScroll` prop on `ScrollView` - Example API data from [Draftbit's Example Data Service](https://example-data.draftbit.com/). <img src="https://i.imgur.com/WCvjoHN.gif" width="200"/> <img src="https://i.imgur.com/jWULIWa.gif" width="200" /> ## Redux Persist - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/redux-persist-asyncstorage) - π [Blog post](https://amanhimself.dev/blog/redux-persist-in-react-native-with-async-storage/) - **Description**: How to configure, integrate and use redux-persist library in a React Native & Expo app and dynamically change the UI based on the state updates. This example uses: - Expo SDK 40 - react-navigation v5 (bottom-tabs) - redux, react-redux (with hooks), redux-thunk, redux-persist - Example API data from [Draftbit's Example Data Service](https://example-data.draftbit.com/). <img src="https://i.imgur.com/tP4SSP5.gif" width="200" /> ## Forms with Formik - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/forms-with-formik) - π [Blog post](https://blog.jscrambler.com/creating-and-validating-react-native-forms-with-formik/) - **Description**: In this post, let's take a look at how to integrate Formik along with Yup in a React Native app to create forms and validate them. We are also going to cover how to change the focus of one input field to another using a device's keyboard by forwarding the ref created using a `useRef` hook. <img src="https://blog.jscrambler.com/content/images/2020/10/jscrambler-blog-creating-forms-react-native-formik-4.gif" width="200"/> <img src="https://blog.jscrambler.com/content/images/2020/10/jscrambler-blog-creating-forms-react-native-formik-8.gif" width="200" /> ## Animated Header View on a Scroll with React Native Animated API - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/animate-header-on-scroll) - π [Blog post](https://amanhimself.dev/blog/animate-header-view-on-scroll-with-react-native-animated-api/) - **Description**: In this tutorial, let's explore a way to create a header view component that animates on the scroll position of the ScrollView component from React Native. We will go through the basics of creating a new Animated value as well as explaining the significance of functions and properties like interpolation, extrapolate, contentOffset, and so on. This example uses: - Expo SDK 38 - React Native Animated API <img src="https://blog.jscrambler.com/content/images/2020/10/jscrambler-blog-how-to-animate-header-view-with-react-native-animated-5.gif" width="200" /> <img src="https://blog.jscrambler.com/content/images/2020/10/jscrambler-blog-how-to-animate-header-view-with-react-native-animated-6.gif" width="200" /> ## Chat app with Expo + Firebase + Firestore + react-native-gifted-chat + react-native-paper + react-navigation v5 - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/ChatApp) - π **Blog post series**: [Part1](https://amanhimself.dev/blog/chat-app-with-react-native-part-1) | [Part2](https://amanhimself.dev/blog/chat-app-with-react-native-part-2) | [Part3](https://amanhimself.dev/blog/chat-app-with-react-native-part-3) | [Part4](https://amanhimself.dev/blog/chat-app-with-react-native-part-4) | [Part5](https://amanhimself.dev/blog/chat-app-with-react-native-part-5) | [Part6](https://amanhimself.dev/blog/chat-app-with-react-native-part-6) <img src="https://miro.medium.com/max/684/1*7UqfiUWxFDtSyR2_CQoigQ.gif" width="200" /> <img src="https://miro.medium.com/max/684/1*5owHh4tZ5mmOyVfsn9kOwA.gif" width="200" /> <img src="https://miro.medium.com/max/684/1*Ztwt_qL30dreUv_JMvhhwg.gif" width="200" /> <img src="https://miro.medium.com/max/684/1*nDaN1lXF75iWEWg6X-0sqQ.gif" width="200" /> <img src="https://miro.medium.com/max/714/1*_X5Ye5IJpkOYbUsED8ELYg.gif" width="200" /> ## Create onBoarding screens with react-native-viewpager - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/onboarding-viewpager) - π [Blog post](https://blog.logrocket.com/how-to-create-onboarding-screens-with-react-native-viewpager/) - **Description**: In this tutorial, weβll look at one of the ways to create onboarding screens in a React Native app. We are going to use a React Native community package, called react-native-viewpager, that allows us to swipe left or right between different pages where each page has some data to display. <img src="https://i0.wp.com/blog.logrocket.com/wp-content/uploads/2020/09/completenavigationflow.gif?resize=362%2C748&ssl=1" width="200" /> ## Remove Tab bar Border Width - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/remove-tabbar-border) - π [Blog post](https://amanhimself.dev/blog/react-navigation-remove-tab-bar-border/) This example uses: - Expo SDK 44 - [React Navigation v6](https://reactnavigation.org/docs/getting-started) <img src="https://i.imgur.com/ttIMI5V.png" width="200"/> <img src="https://i.imgur.com/WqR3X9I.png" width="200"/> ## Create Custom Custom Wavy Headers with react-native-svg - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/onboarding-viewpager) - π [Blog post](https://amanhimself.dev/blog/create-custom-headers-with-react-native-svg) <img src="https://miro.medium.com/max/598/1*aivsFUf_OF6mYBSfOCGrTQ.gif" width="200" /> ## Using Styled Components in React Native and Expo - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/rnStyledComponents) - π [Blog post](https://blog.logrocket.com/how-to-use-styled-components-with-react-native/) <img src="https://blog.logrocket.com/wp-content/uploads/2020/10/completedui-nocdn.png" width="200" /> ## Using react-native-image-picker - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/rnImagePickerExample) - π [Blog post](https://amanhimself.dev/blog/how-to-use-react-native-image-picker) <img src="https://crowdbotics.ghost.io/content/images/2020/04/cb14.png" width="200" /> ## Handle Navigation in WebViews - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/rnWebViewCustomNav) - π [Blog post](https://amanhimself.dev/blog/handle-navigation-in-webviews-react-native) <img src="https://miro.medium.com/max/377/1*r2li3qWatN2JM_Pl9nhGBA.gif" width="200" /> ## Getting Started with react-navigation v5 - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/reactnav5-stack-navigator) - π [Blog post](https://amanhimself.dev/blog/stack-navigator-with-react-navigation-v5) <img src="https://miro.medium.com/max/825/1*IUWdHNEwH4bLtRzBwQ8yng.gif" width="400" /> ## Nesting Tab and Stack Navigation Patterns in react-navigation v5 - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/reactnav5-tab-navigator) - π [Blog post](https://amanhimself.dev/blog/nested-navigators-in-react-native) <img src="https://miro.medium.com/max/369/1*gCs24QDMEQ_D6DcDxjiALw.gif" width="200" /> ## Getting Started with Expo and React Native with Hooks & Redux (Hooks!) - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/master/reactnav5-tab-navigator) - π **Blog post series**: [Part 1](https://amanhimself.dev/blog/getting-started-with-react-native-expo-hooks-2020) | [Part 2](https://amanhimself.dev/blog/redux-with-react-native-hooks) <img src="https://miro.medium.com/max/381/1*BJYPQHfTF0wKbZ9CIIhL0g.gif" width="200" /> ## Change status bar style config based on route with useIsFocused & react-navigation v6 - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/main/02-statusbar-config-based-on-route) **Uses** - [`useIsFocused` hook from React Navigation](https://reactnavigation.org/docs/status-bar/) - [`expo-status-bar`](https://docs.expo.dev/versions/latest/sdk/status-bar/) <img src="https://i.imgur.com/sS9ASUg.gif" width="200" /> ## Create a custom hook to change status bar styles with useFocusEffect & react-navigation v6 > **Warning** > Example Outdated. I wrote this status bar hook without knowing that the React Navigation library provides a `useIsFocused` hook. I [updated my example using their technique that also works nicely with `expo-status-bar`](#change-status-bar-style-config-based-on-route-with-useisfocused--react-navigation-v6). - π [Repo](https://github.com/amandeepmittal/react-native-examples/tree/main/01-custom-status-bar-hook) - π [Blog post series](https://amanhimself.dev/blog/create-custom-status-bar-hook-react-navigation) <img src="https://i.imgur.com/sS9ASUg.gif" width="200" />