React Native Questions
Warm up for your React Native interview with most asked questions and answers for junior, mid, and senior roles.
What are refs and why are they useful?
Show AnswerHide 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.
What are some ways to add style to a react native component?
Show AnswerHide Answer
- Inline styling
- StyleSheet
- Styled Components
- Tailwind
What are components?
Show AnswerHide Answer
Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions
What is justifyContent and alignItems in React Native?
Show AnswerHide 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
When should you use Flatlist or ScrollView?
Show AnswerHide 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
What is JSX?
Show AnswerHide Answer
JSX is an HTML like syntax used by React and React Native that allows you to write HTML inside of JavaScript.
What are props in React Native?
Show AnswerHide Answer
Props can be simply the component properties or pieces of data that are passed to the component.
What are native apps?
Show AnswerHide 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.
What is React Native
Show AnswerHide 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.
What are some benefits of using React Native?
Show AnswerHide Answer
- Code Reusability and Cross-platform compatibility
- Native Look and Feel
- Large Community Support
- Live/ Hot Reloading
- Great Performance
- Open-source framework
What are some ways to persist data in React Native?
Show AnswerHide Answer
- Async Storage
- SQLite
- Realm DB
- Watermelon DB
- MMKV
Explain some of the tradeoffs between building a React Native and building a “true” native app.
Show AnswerHide 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.
What is the difference between React Native and ReactJS?
Show AnswerHide 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
What is State in React Native?
Show AnswerHide 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