React Native Questions

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

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.