React Native Questions

Warm up for your React Native interview with most asked questions and answers for junior, mid, and senior roles.

Junior

What are refs and why are they useful?

Show Answer

Refs provide a way to access a DOM node or component instance from within a component. In React, you can create a reference using useRef() hook.

Junior

What are some ways to add style to a react native component?

Show Answer
  • Inline styling
  • StyleSheet
  • Styled Components
  • Tailwind
Junior

What are components?

Show Answer

Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions

Junior

What is justifyContent and alignItems in React Native?

Show Answer

justifyContent is used to align the content on the main axis. alignItems is used to align the content on the cross axis.

 

When flexDirection: "row", Main Axis is left to right

When flexDirection: "column", Main Axis is top to bottom

Junior

When should you use Flatlist or ScrollView?

Show Answer

Use Flatlist when:

  • A big list of similar items
  • A list of items that you don't know the length

 

Use Scrollview when:

  • A small list of items
  • Generic items in a scrollable area
Junior

What is JSX?

Show Answer

JSX is an HTML like syntax used by React and React Native that allows you to write HTML inside of JavaScript.

Junior

What are props in React Native?

Show Answer

Props can be simply the component properties or pieces of data that are passed to the component.

Junior

What are native apps?

Show Answer
  • A native app is an app that is developed for use on a specific platform.
  • For example Swift and Objective-C for native iOS apps and Java and Kotling for Android native apps.
Junior

What is React Native

Show Answer

React Native is an open-source mobile application framework created by Facebook.

 

It is used to develop applications for Android, iOS, Web, and UWP by enabling developers to use React and native platform capabilities.

Junior

What are some benefits of using React Native?

Show Answer
  • Code Reusability and Cross-platform compatibility
  • Native Look and Feel
  • Large Community Support
  • Live/ Hot Reloading
  • Great Performance 
  • Open-source framework
Junior

What are some ways to persist data in React Native?

Show Answer
  • Async Storage
  • SQLite
  • Realm DB
  • Watermelon DB
  • MMKV
Junior

Explain some of the tradeoffs between building a React Native and building a “true” native app.

Show Answer

If you are building an app that depends a lot on native libraries, you may want to consider building a Native app, because native provides superior performance and gives developers complete access to the capabilities of each device. But you will have two codebases for your app, one for Android and one for iOS.

 

On the other hand, if your application does not depends a lot on native libraries, you may want to build a React Native app, because it is easier to maintain and it is easier to test.

Junior

What is the difference between React Native and ReactJS?

Show Answer
  • ReactJS main focus is Web Development
  • ReactJS is a Javascript library
  • React uses HTML tags like p,span,div, etc...
  • React Native is focused on Mobile Development
  • React Native is a mobile framework that uses Javascript Engine
  • Both are open-source and supports the JSX syntax
Junior

What is State in React Native?

Show Answer

State is a mutable data structure that is used to contain data about a component. A component's state can change over time; whenever it changes, the component re-renders

Mid

How are props and state different?

Show Answer

Props are immutable. State is mutable.

Mid

How are Hot Reloading and Live Reloading in React Native different?

Show Answer

Hot Reloading

  • It only reloads the file that changed
  • The state of your app is maintained.
  • Modify your code without any delay.

 

Live Reloading

  • It reloads the whole app.
  • The state of your app is reseted.
Mid

What is AppRegistry?

Show Answer

AppRegistry is the entry point to your React Native application. It is like the root component of your application.

Mid

What does StyleSheet.create do and why is it useful?

Show Answer

StyleSheet.create is used to create a stylesheet object that you can use to style your components.

 

It's useful because moving your styles to a stylesheet object makes it easier to manage, reuse styles, and improve performance.

Mid

What is AsyncStorage?

Show Answer

AsyncStorage is a simple, unencrypted, asynchronous, persistent, key-value storage system that is global to the app.

Mid

List some packages that implement native modules for both iOS and Android

Show Answer
  • Camera
  • Bluetooth
  • Contacts
  • Date Picker
  • Image Picker
Mid

List some ways you can optimize an application

Show Answer
  • Use FlatLIst or SectionList to render large lists.
  • Remove console statements
  • Memoize expensive computations (memo HOC, useCallback and useMemo)
  • Cache image locally
  • Use WebP image format
  • Use Native driver with Animated API
  • Use Hermes and ProGuard
Mid

What is props drilling?

Show Answer

Prop drilling is the term for passing data through several nested children components. It can cause issues with component reusability and app performance.

Mid

How do you handle different screen sizes in React Native?

Show Answer

You can use PixelRatio which gives you access to the device's pixel density and font scale, so you can use it to handle different screen sizes, but there is a couple of libraries that provide some tools to handle responsiveness, like:

 

  • react-native-responsive-screen
  • react-native-responsive-fontsize
  • react-native-auto-size-text
Mid

What are hooks in React Native and what are some of the advantages?

Show Answer

Hooks allow you to write functions that can be used in React components. They are a way to write code in a modular and reusable way, using all the React features.

Mid

What are Container/Smart components?

Show Answer

Container components are the ones that manage the state of the application. They receive the props and pass them to the presentational components.

Mid

What are Presentational/Dumb Components?

Show Answer

Presentational components are the ones that receive the props and render the UI. They don't manage or change the state of the application.

Mid

How useEffect works in React Native?

Show Answer

It is a hook that is called after the component is rendered for the first time, before the component is unmounted, and also when some of the props in the dependency array changes.

Mid

What is the significance of keys in React Native?

Show Answer

It helps React identify which items have changed, added, or removed, increasing its performance when diffing between the virtual and real DOM

Mid

How to use animations in React Native?

Show Answer

You can implement animations in React Native using the Animated API or react-native-reanimated library

Mid

What is Redux and why it is used?

Show Answer

Redux is a state management pattern. It helps you manage the application state, synchronizing the application's state between multiple parts of the application.

 

It has three main parts:

  • Reducers: A function that returns the next state given the current state and an action to handle.
  • Actions: An object that describes an event. It has a type property that defines the event, and a payload property that contains the data associated with the event.
  • Store: A single source of truth for the application state. It is the only source of truth for the application state.
Mid

How to use SVG in React Native?

Show Answer

You can use SVG in React Native using the react-native-svg library

Mid

What is Expo?

Show Answer

Expo is a platform for building native apps for iOS and Android. It provides a set of tools that simplify the development of React Native apps.

Mid

How do you debug React Native apps?

Show Answer

You can use Chrome Dev Tools, react-native-debugger, Flipper or Reactotron to debug React Native apps.

Mid

What is the difference between a functional component and a class component?

Show Answer

A functional component is a function that returns a React element. A class component is a class that extends React.Component.

Mid

What is the difference between useState and useReducer?

Show Answer

useState is a hook that allows you to manage the state of a component. It is a function that returns an array with two elements: the current state and a function to update the state, and it uses useReducer under the hood.

 

useReducer gives you more control over the state of your component. It takes a reducer function and initial state as arguments and returns the state and dispatch method.

Mid

What is Gesture Responder System?

Show Answer

The gesture responder system manages the lifecycle of gestures in your app. A touch can go through several phases as the app determines what the user's intention is.

 

For example, the app needs to determine if the touch is scrolling, sliding on a widget, or tapping. This can even change during the duration of a touch. There can also be multiple simultaneous touches.

Senior

How many threads run in a React Native app?

Show Answer

We can say there are three threads that mainly run a React Native app:

 

  • UI thread — this is the native thread used to run Swift/Objective C on iOS devices and Java/Kotlin on Android devices, an application’s UI is manipulated solely on this thread. Here the application’s Views are rendered and users of the app can interact with the OS. 
  • JavaScript thread — this is the thread that executes JavaScript separately via a Javascript Engine. An application’s logic – including which Views to display and in what manner they are displayed.
    Senior

    What is Flux?

    Show Answer

    Flux is an architecture for creating data layers in JavaScript applications. It was designed on Facebook along with the React view library.

     

    It places a focus on creating explicit and understandable update paths for your application's data, which makes tracing changes during development simpler and makes bugs easier to track down and fix.

    Senior

    What are some concepts about React Native life-cycle?

    Show Answer

    React Native has a lifecycle of three stages:

    • Mounting
    • Updating
    • Unmounting

    Mounting is the process of creating a native view and mounting it to the screen.

    Updating is the process of updating the native view.

    Unmounting is the process of removing the native view from the screen.

    With React Hooks we can use useEffect and useState to manipulate and trigger these stages

    Senior

    What JavaScript engine does React native use?

    Show Answer

    On iOS simulators and devices, Android emulators and devices React Native uses JavaScriptCore.

    Senior

    What is and when should you use useMemo?

    Show Answer

    useMemo is a React hook that allows you to memoize the return of expensive functions, avoiding calling them on every render.

    Senior

    What is and when should you use useCallback?

    Show Answer

    useCallback is a React hook that returns a memoized version of the callback that only changes if one of the dependencies has changed.

     

    It's useful when you have a component in which the child is re-rendering too often, so the function object returned from useCallback will be the same between re-renders.

    Senior

    What is and when should you use memo (HOC)?

    Show Answer

    memo is a React High Order Component that will cause React to skip rendering a component if its props have not changed.

    Senior

    What happens when you call setState

    Show Answer
    1. React will merge the object that will pass in setState to the current state of the component
    2. The reconciliation process will start.
    3. React will construct a new tree of React Elements with your changes (Virtual DOM)
    4. React will diff this new tree with the previous element tree (Real DOM)
    5. By doing this the UI will be re-rendered by only making updates where absolutely necessary.
    Senior

    What is meant by InteractionManager, and why it is Important?

    Show Answer

    InteractionManager allows long-running work to be scheduled after any interactions/animations have completed. In particular, this allows JavaScript animations to run smoothly.

    Senior

    Explain the Flow of Redux

    Show Answer

    Redux follows the unidirectional data flow.

    So, an action is dispatched to the store's reducer along with the current state of the store. The reducer then returns a new state based on the action. The new state is then passed to the store's subscribers.

    Senior

    What is Component Driven Development (CDD)?

    Show Answer

    Component-Driven Development (CDD) is a development methodology that anchors the build process around components.

     

    It is a process that builds UIs from the “bottom-up” by starting at the level of components and ending at the level of pages or screens.

    Senior

    What is the difference between ShadowDOM and VirtualDOM?

    Show Answer

    Virtual DOM is a copy of the whole DOM object.

    On the other hand, Shadow DOM creates small pieces of the DOM object which has isolated scope for the element they represent.

    Senior

    What is Higher Order Component or HOC?

    Show Answer

    A higher-order component transforms a component into another component.

     

    A HOC composes the original component by wrapping it in a container component. A HOC is a pure function with zero side effects.

    Senior

    List some concepts about React Native Architecure?

    Show Answer

    Old Architecture

    • The JavaScript thread.
    • The Native/UI thread.
    • The bridge.

    New Architecture

    • The bridge will be replaced by JSI
    • Ability to swap the JavaScriptCore with other Engines
    • Complete Interoperability between all threads
    • Web-like Rendering system
    • Time-sensitive tasks can be executed synchronously
    • Lazy Loading of Turbo Modules
    • Static Type Checking for compatibility between JS and Native Side
    Senior

    What is React Native Bridge?

    Show Answer

    The Bridge in React Native is the layer that handles the interaction between JavaScript and the Native modules.

    It is primarily a carrier layer that conducts asynchronously grouped feedback messages from JavaScript to Native modules.

    Senior

    What is Fabric in React Native?

    Show Answer

    Fabric is React Native's new rendering system, conceptual evolution of the legacy render system.

    The core principles are to unify more render logic in C++, improve interoperability with host platforms, and unlock new capabilities for React Native.

    Development began in 2018 and in 2021, React Native in the Facebook app is backed by the new renderer.

    Senior

    What is OTA (Over the air updates)?

    Show Answer

    Over the Air updates are updates that are downloaded directly to the device, OTA allows us to send updated Javascript bundles directly to users.

    Senior

    Does React Native have a Virtual DOM?

    Show Answer

    Yes, React-Native creates a tree hierarchy to define the initial layout and creates a diff of that tree on each layout change to optimize the renderings.

    But React Native manages the UI updates through couple of architecture layers that in the end translate how views should be rendered while trying to optimize the changes to a minimum in order to deliver the fastest rendering possible.