React Native Questions

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

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.