Here are 50 React Native interview questions along with their answers. These will help you prepare for interviews:
Answer:
React Native is an open-source framework developed by Facebook for building mobile applications using JavaScript and React. It allows you to use the same codebase for both iOS and Android apps, while rendering the components using native APIs.
Â
Â
Answer:
Answer:
View
, Text
, and Image
instead of HTML elements.Answer:
Props (short for properties) are used to pass data from a parent component to a child component in React Native. They are immutable and cannot be modified by the child component.
Â
Answer:
setState
.Answer:
The Virtual DOM is a lightweight in-memory representation of the actual DOM. React Native uses it to optimize the process of updating the real DOM by performing a diffing algorithm and applying only the changes to the actual DOM, improving performance.
Â
Answer:
Answer:
Hot reloading allows developers to immediately see the changes in the app without losing the current state. It speeds up the development process by providing instant feedback on code modifications.
Â
Answer:
Navigation in React Native can be managed using libraries like:
Answer:
setState
in React Native?Answer:setState
is used to update the state of a component. When the state changes, React Native re-renders the component to reflect the new state.
Â
Answer:
Flexbox is a layout model used in React Native for arranging components in rows or columns. It provides powerful controls like alignment, distribution, and responsiveness to design the UI.
Â
Answer:
keyExtractor
in FlatList?Answer:
The keyExtractor
function in a FlatList
is used to provide a unique key for each list item. This helps React Native to efficiently update and render only the necessary items in the list.
Â
Answer:
setState
.state
.useEffect
hook in React Native?Answer:useEffect
is a hook that allows you to perform side effects in functional components. It is similar to lifecycle methods like componentDidMount
and componentWillUnmount
.
Â
Answer:
style
prop directly on the component.StyleSheet.create()
to define styles separately.styled-components
and tailwind-rn
.Answer:
API requests can be made using:
Answer:
shouldComponentUpdate
method?Answer:shouldComponentUpdate
allows you to optimize performance by preventing unnecessary re-renders. It is used to compare current props and state with the next ones to determine if the component needs to update.
Â
Answer:
The React Native bridge allows JavaScript code to communicate with native code (iOS and Android). The bridge converts JSON data between JavaScript and native components and ensures performance optimization.
Â
Answer:
Redux is a state management library used for managing and centralizing application state. In React Native, Redux is often used with react-redux
to provide a predictable state container, making it easier to manage the application’s state.
Â
Answer:
Answer:
Native Modules allow React Native to communicate with native code, enabling access to features like camera, GPS, or other device APIs that are not available via JavaScript.
Â
useState
and useReducer
.Answer:
useRef
in React Native?Answer:useRef
is used to persist values between renders without causing a re-render. It’s useful for referencing DOM elements or maintaining mutable values that do not trigger a re-render when changed.
Â
Answer:
Answer:
You can use libraries like:
Answer:
Hermes is a JavaScript engine optimized for running React Native apps. It improves performance by reducing memory usage, decreasing app size, and improving start-up time.
Â
Answer:
HOCs are functions that take a component and return a new component with additional props or behavior. They are often used for code reuse, like adding authentication or logging.
Â
View
component in React Native?Answer:View
is a core component that acts as a container for other components. It is used for layout and styling, similar to a <div>
in HTML.
Â
TouchableOpacity
?Answer:TouchableOpacity
is a component that wraps elements to make them touchable and adds a fade effect when pressed.
Â
AsyncStorage
module?Answer:AsyncStorage
is a key-value storage system that allows you to persist data locally in React Native apps. It is often used to store user preferences or session data.
Â
Answer:
Answer:
Error boundaries are React components that catch JavaScript errors in their child components and log the errors, preventing the app from crashing.
Â
Platform
module in React Native?Answer:
The Platform
module allows you to check the platform (iOS or Android) your app is running on and tailor code accordingly.
Â
react-native link
?Answer:react-native link
was used to link native modules to a React Native project. However, it’s deprecated and now auto-linking is done in React Native 0.60 and higher.
Â
Answer:
React Native supports deep linking to navigate to specific parts of your app from external links or notifications. You can configure it using Linking
API.
Â
Answer:
useEffect
and componentDidMount
?Answer:useEffect
is a hook for handling side effects in functional components, while componentDidMount
is a lifecycle method in class components that runs after the component mounts.
Â
Answer:
You can use tools like:
Answer:
Native dependencies are libraries that provide access to native device features (camera, GPS, etc.) and require linking with native code.
Â
react-native run-android
?Answer:react-native run-android
is a command used to build and launch a React Native app on an Android emulator or device.
Â
Answer:
Push notifications can be handled using libraries like:
react-native-firebase
.SafeAreaView
in React Native?Answer:SafeAreaView
is a component that ensures content is rendered within the safe area boundaries of a device (i.e., not obstructed by notch or gesture areas).
Â
Answer:
You can add custom fonts in React Native by placing the font files in the assets directory and linking them through react-native link
.
Â
Answer:
React Native provides an Animated
API to create complex animations by controlling the properties of components.
Â
Answer:
You can access the camera using third-party libraries like react-native-camera or react-native-image-picker.
Â
Answer:
Deep linking can be handled using the Linking
API or React Navigation’s deep linking configuration to handle URL schemes and Universal Links.
Â
AppRegistry
in React Native?Answer:AppRegistry
is used to register the main component of the app, which is then rendered inside the root view of the mobile app.
These are top 50 react native interview questions