{"id":12536,"date":"2024-09-04T10:00:14","date_gmt":"2024-09-04T04:30:14","guid":{"rendered":"https:\/\/www.placementpreparation.io\/blog\/?p=12536"},"modified":"2025-02-27T12:56:21","modified_gmt":"2025-02-27T07:26:21","slug":"react-native-interview-questions-for-freshers","status":"publish","type":"post","link":"https:\/\/www.placementpreparation.io\/blog\/react-native-interview-questions-for-freshers\/","title":{"rendered":"Top React Native Interview Questions for Freshers"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Are you preparing for your first React Native interview and wondering what questions you might face? Understanding the key React Native interview questions for freshers can give you more clarity.<\/p><p>This blog is here to help you get ready with practical questions that test your real-world problem-solving skills. We&rsquo;ve gathered some of the most common basic React Native interview questions that freshers often encounter.<\/p><p>With this guide, you&rsquo;ll be well-prepared to tackle these React Native interview questions and answers for freshers and make a strong impression in your interview.<\/p><p><a href=\"https:\/\/www.guvi.in\/mlp\/fsd-student-program-wp?utm_source=placement_preparation&amp;utm_medium=blog_banner&amp;utm_campaign=react_native_interview_questions_for_freshers_horizontal\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" class=\"alignnone wp-image-14310 size-full\" src=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/01\/fsd-student-program-banner-horizontal.webp\" alt=\"fsd student program banner horizontal\" width=\"2270\" height=\"600\" srcset=\"https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/01\/fsd-student-program-banner-horizontal.webp 2270w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/01\/fsd-student-program-banner-horizontal-300x79.webp 300w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/01\/fsd-student-program-banner-horizontal-1024x271.webp 1024w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/01\/fsd-student-program-banner-horizontal-768x203.webp 768w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/01\/fsd-student-program-banner-horizontal-1536x406.webp 1536w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/01\/fsd-student-program-banner-horizontal-2048x541.webp 2048w, https:\/\/www.placementpreparation.io\/blog\/wp-content\/uploads\/2025\/01\/fsd-student-program-banner-horizontal-150x40.webp 150w\" sizes=\"(max-width: 2270px) 100vw, 2270px\"><\/a><\/p><h2 id=\"practice-react-native-interview-questions\">Practice React Native Interview Questions and Answers<\/h2><p>Here are the top 50 React Native Interview questions for freshers with answers:<\/p><h3 id=\"define-react-native\">1. What is React Native, and how does it differ from React?<\/h3><p><strong>Answer:<\/strong><\/p><p>React Native is a framework for building mobile applications using React. Unlike React, which targets web browsers, React Native targets mobile platforms (iOS and Android) and uses native components instead of web components.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { Text, View } from &lsquo;react-native&rsquo;;<\/p>\n<\/div><\/div><h3 id=\"new-project-setup\">2. How do you set up a new React Native project?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>npx react-native init<\/strong> command followed by the project name to set up a new React Native project.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>npx react-native init MyNewProject<\/p>\n<\/div><\/div><h3 id=\"appregistry-purpose\">3. What is the purpose of the AppRegistry in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p><strong>AppRegistry<\/strong> is the entry point to run a React Native application. It tells React Native which component to render as the root component.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { AppRegistry } from &lsquo;react-native&rsquo;;<br>\nimport App from &lsquo;.\/App&rsquo;;<\/p>\n<p>AppRegistry.registerComponent(&lsquo;MyApp&rsquo;, () =&gt; App);<\/p>\n<\/div><\/div><h3 id=\"run-app-on-emulator\">4. How do you run a React Native app on an iOS or Android emulator?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>npx react-native run-ios<\/strong> or <strong>npx react-native run-android<\/strong> commands to run the app on the respective emulator.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>npx react-native run-ios<br>\nnpx react-native run-android<\/p>\n<\/div><\/div><h3 id=\"explain-jsx-usage\">5. What is JSX, and how is it used in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>JSX is a syntax extension for JavaScript that allows you to write HTML-like code within JavaScript. In React Native, JSX is used to describe the UI.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const App = () =&gt; (<br>\n&lt;View&gt;<br>\n&lt;Text&gt;Hello, world!&lt;\/Text&gt;<br>\n&lt;\/View&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"create-functional-component\">6. How do you create a functional component in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>A functional component is a simple function that returns JSX to render UI elements.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const MyComponent = () =&gt; (<br>\n&lt;View&gt;<br>\n&lt;Text&gt;My Functional Component&lt;\/Text&gt;<br>\n&lt;\/View&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"apply-component-styles\">7. How do you apply styles to components in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>StyleSheet<\/strong> API or inline styles to apply styles to React Native components.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { StyleSheet, View, Text } from &lsquo;react-native&rsquo;;<\/p>\n<p>const styles = StyleSheet.create({<br>\ncontainer: {<br>\npadding: 20,<br>\nbackgroundColor: &lsquo;lightblue&rsquo;,<br>\n},<br>\ntext: {<br>\nfontSize: 20,<br>\ncolor: &lsquo;darkblue&rsquo;,<br>\n},<br>\n});<\/p>\n<p>const App = () =&gt; (<br>\n&lt;View style={styles.container}&gt;<br>\n&lt;Text style={styles.text}&gt;Styled Text&lt;\/Text&gt;<br>\n&lt;\/View&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"handle-component-state\">8. How do you handle component state in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>useState<\/strong> hook to manage state within a functional component.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { useState } from &lsquo;react&rsquo;;<br>\nimport { View, Button, Text } from &lsquo;react-native&rsquo;;<\/p>\n<p>const App = () =&gt; {<br>\nconst [count, setCount] = useState(0);<\/p>\n<p>return (<br>\n&lt;View&gt;<br>\n&lt;Text&gt;{count}&lt;\/Text&gt;<br>\n&lt;Button title=&rdquo;Increment&rdquo; onPress={() =&gt; setCount(count + 1)} \/&gt;<br>\n&lt;\/View&gt;<br>\n);<br>\n};<\/p>\n<\/div><\/div><h3 id=\"data-passing-via-props\">9. How do you pass data between components in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Pass data between components using props. The parent component passes data to the child component as a prop.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const ChildComponent = ({ message }) =&gt; (<br>\n&lt;Text&gt;{message}&lt;\/Text&gt;<br>\n);<\/p>\n<p>const ParentComponent = () =&gt; (<br>\n&lt;ChildComponent message=&rdquo;Hello from parent!&rdquo; \/&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"conditional-rendering-components\">10. How do you conditionally render components in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use conditional statements like <strong>if-else<\/strong> or ternary operators to render components based on certain conditions.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const App = ({ isLoggedIn }) =&gt; (<br>\n&lt;View&gt;<br>\n{isLoggedIn ? &lt;Text&gt;Welcome back!&lt;\/Text&gt; : &lt;Text&gt;Please log in.&lt;\/Text&gt;}<br>\n&lt;\/View&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"setup-navigation\">11. How do you set up navigation in a React Native app?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>react-navigation<\/strong> library to handle navigation. Start by installing the necessary packages and setting up a <strong>NavigationContainer<\/strong>.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { NavigationContainer } from &lsquo;@react-navigation\/native&rsquo;;<br>\nimport { createStackNavigator } from &lsquo;@react-navigation\/stack&rsquo;;<\/p>\n<p>const Stack = createStackNavigator();<\/p>\n<p>const App = () =&gt; (<br>\n&lt;NavigationContainer&gt;<br>\n&lt;Stack.Navigator&gt;<br>\n&lt;Stack.Screen name=&rdquo;Home&rdquo; component={HomeScreen} \/&gt;<br>\n&lt;Stack.Screen name=&rdquo;Details&rdquo; component={DetailsScreen} \/&gt;<br>\n&lt;\/Stack.Navigator&gt;<br>\n&lt;\/NavigationContainer&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"navigate-between-screens\">12. How do you navigate between screens in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>navigation.navigate()<\/strong> method provided by the <strong>react-navigation<\/strong> library to move between screens.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const HomeScreen = ({ navigation }) =&gt; (<br>\n&lt;Button title=&rdquo;Go to Details&rdquo; onPress={() =&gt; navigation.navigate(&lsquo;Details&rsquo;)} \/&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"pass-route-parameters\">13. How do you pass parameters to routes in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Pass parameters to routes using the <strong>navigate()<\/strong> method, and access them using <strong>route.params<\/strong>.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>\/\/ Navigating with parameters<br>\nnavigation.navigate(&lsquo;Details&rsquo;, { itemId: 42 });<\/p>\n<p>\/\/ Accessing parameters<br>\nconst { itemId } = route.params;<\/p>\n<\/div><\/div><h3 id=\"implement-deep-linking\">14. How do you handle deep linking in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Configure deep linking by setting up the <strong>Linking<\/strong> module and defining URL patterns in your navigation.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const linking = {<br>\nprefixes: [&lsquo;myapp:\/\/&rsquo;],<br>\nconfig: {<br>\nscreens: {<br>\nHome: &lsquo;home&rsquo;,<br>\nDetails: &lsquo;details\/:id&rsquo;,<br>\n},<br>\n},<br>\n};<\/p>\n<p>const App = () =&gt; (<br>\n&lt;NavigationContainer linking={linking}&gt;<br>\n{\/* Navigator setup *\/}<br>\n&lt;\/NavigationContainer&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"use-bottom-tab-navigator\">15. How do you implement a bottom tab navigator in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>createBottomTabNavigator<\/strong> function from <strong>@react-navigation\/bottom-tabs<\/strong> to implement a tab-based navigation.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { createBottomTabNavigator } from &lsquo;@react-navigation\/bottom-tabs&rsquo;;<\/p>\n<p>const Tab = createBottomTabNavigator();<\/p>\n<p>const App = () =&gt; (<br>\n&lt;NavigationContainer&gt;<br>\n&lt;Tab.Navigator&gt;<br>\n&lt;Tab.Screen name=&rdquo;Home&rdquo; component={HomeScreen} \/&gt;<br>\n&lt;Tab.Screen name=&rdquo;Settings&rdquo; component={SettingsScreen} \/&gt;<br>\n&lt;\/Tab.Navigator&gt;<br>\n&lt;\/NavigationContainer&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"state-vs-props-difference\">16. What is the difference between state and props in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>State is a component&rsquo;s internal data, managed within the component itself, while props are external data passed to the component by its parent.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>\/\/ State (internal)<br>\nconst [count, setCount] = useState(0);<\/p>\n<p>\/\/ Props (external)<br>\nconst ChildComponent = ({ message }) =&gt; &lt;Text&gt;{message}&lt;\/Text&gt;;<\/p>\n<\/div><\/div><h3 id=\"use-context-api\">17. How do you use the Context API for state management in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Create a context using <strong>React.createContext<\/strong>, and use <strong>Provider<\/strong> to pass the state to child components.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const MyContext = React.createContext();<\/p>\n<p>const App = () =&gt; {<br>\nconst [value, setValue] = useState(&lsquo;Hello&rsquo;);<\/p>\n<p>return (<br>\n&lt;MyContext.Provider value={value}&gt;<br>\n&lt;ChildComponent \/&gt;<br>\n&lt;\/MyContext.Provider&gt;<br>\n);<br>\n};<\/p>\n<\/div><\/div><h3 id=\"use-usereducer-hook\">18. How do you use the useReducer hook in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p><strong>useReducer<\/strong> is an alternative to <strong>useState<\/strong> for managing more complex state logic in React Native components.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const reducer = (state, action) =&gt; {<br>\nswitch (action.type) {<br>\ncase &lsquo;increment&rsquo;:<br>\nreturn { count: state.count + 1 };<br>\ndefault:<br>\nreturn state;<br>\n}<br>\n};<\/p>\n<p>const App = () =&gt; {<br>\nconst [state, dispatch] = useReducer(reducer, { count: 0 });<\/p>\n<p>return (<br>\n&lt;View&gt;<br>\n&lt;Text&gt;{state.count}&lt;\/Text&gt;<br>\n&lt;Button title=&rdquo;Increment&rdquo; onPress={() =&gt; dispatch({ type: &lsquo;increment&rsquo; })} \/&gt;<br>\n&lt;\/View&gt;<br>\n);<br>\n};<\/p>\n<\/div><\/div><h3 id=\"manage-global-state\">19. How do you manage global state in a React Native app using Redux?<\/h3><p><strong>Answer:<\/strong><\/p><p>Set up Redux by creating a store, defining reducers, and using the <strong>Provider<\/strong> to make the store available to the app.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { createStore } from &lsquo;redux&rsquo;;<br>\nimport { Provider } from &lsquo;react-redux&rsquo;;<\/p>\n<p>const reducer = (state = { count: 0 }, action) =&gt; {<br>\nswitch (action.type) {<br>\ncase &lsquo;INCREMENT&rsquo;:<br>\nreturn { &hellip;state, count: state.count + 1 };<br>\ndefault:<br>\nreturn state;<br>\n}<br>\n};<\/p>\n<p>const store = createStore(reducer);<\/p>\n<p>const App = () =&gt; (<br>\n&lt;Provider store={store}&gt;<br>\n&lt;MyComponent \/&gt;<br>\n&lt;\/Provider&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"connect-redux-store\">20. How do you connect a component to the Redux store in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>connect<\/strong> function from <strong>react-redux<\/strong> to map state and dispatch to the component&rsquo;s props.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { connect } from &lsquo;react-redux&rsquo;;<\/p>\n<p>const MyComponent = ({ count, increment }) =&gt; (<br>\n&lt;View&gt;<br>\n&lt;Text&gt;{count}&lt;\/Text&gt;<br>\n&lt;Button title=&rdquo;Increment&rdquo; onPress={increment} \/&gt;<br>\n&lt;\/View&gt;<br>\n);<\/p>\n<p>const mapStateToProps = state =&gt; ({<br>\ncount: state.count,<br>\n});<\/p>\n<p>const mapDispatchToProps = dispatch =&gt; ({<br>\nincrement: () =&gt; dispatch({ type: &lsquo;INCREMENT&rsquo; }),<br>\n});<\/p>\n<p>export default connect(mapStateToProps, mapDispatchToProps)(MyComponent);<\/p>\n<\/div><\/div><h3 id=\"api-requests-handling\">21. How do you make API requests in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>fetch<\/strong> API or a library like <strong>axios<\/strong> to make HTTP requests to a backend service.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>useEffect(() =&gt; {<\/p>\n<p>fetch(&lsquo;https:\/\/api.example.com\/data&rsquo;)<br>\n.then(response =&gt; response.json())<br>\n.then(data =&gt; console.log(data));<br>\n}, []);<\/p>\n<\/div><\/div><h3 id=\"handle-api-errors\">22. How do you handle API request errors in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use <strong>try-catch<\/strong> blocks or <strong>.catch()<\/strong> method to handle errors in API requests.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>useEffect(() =&gt; {<br>\nconst fetchData = async () =&gt; {<br>\ntry {<br>\nconst response = await fetch(&lsquo;https:\/\/api.example.com\/data&rsquo;);<br>\nconst data = await response.json();<br>\nconsole.log(data);<br>\n} catch (error) {<br>\nconsole.error(&lsquo;Error fetching data:&rsquo;, error);<br>\n}<br>\n};<\/p>\n<p>fetchData();<br>\n}, []);<\/p>\n<\/div><\/div><h3 id=\"fetch-data-with-useeffect\">23. How do you use the useEffect hook to fetch data in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>useEffect<\/strong> hook to fetch data when a component mounts, and update the state with the fetched data.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>useEffect(() =&gt; {<br>\nfetch(&lsquo;https:\/\/api.example.com\/data&rsquo;)<br>\n.then(response =&gt; response.json())<br>\n.then(data =&gt; setData(data));<br>\n}, []);<\/p>\n<\/div><\/div><h3 id=\"manage-loading-state\">24. How do you manage loading and error states while fetching data in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use state variables to track loading and error states, and conditionally render UI based on these states.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const [loading, setLoading] = useState(true);<br>\nconst [error, setError] = useState(null);<br>\nconst [data, setData] = useState(null);<\/p>\n<p>useEffect(() =&gt; {<br>\nfetch(&lsquo;https:\/\/api.example.com\/data&rsquo;)<br>\n.then(response =&gt; response.json())<br>\n.then(data =&gt; {<br>\nsetData(data);<br>\nsetLoading(false);<br>\n})<br>\n.catch(error =&gt; {<br>\nsetError(error);<br>\nsetLoading(false);<br>\n});<br>\n}, []);<\/p>\n<\/div><\/div><h3 id=\"implement-api-pagination\">25. How do you implement pagination in React Native while fetching data from an API?<\/h3><p><strong>Answer:<\/strong><\/p><p>Implement pagination by maintaining a page state, fetching data based on the current page, and updating the page number for subsequent requests.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const [page, setPage] = useState(1);<br>\nconst [items, setItems] = useState([]);<\/p>\n<p>const fetchData = () =&gt; {<br>\nfetch(`https:\/\/api.example.com\/data?page=${page}`)<br>\n.then(response =&gt; response.json())<br>\n.then(newItems =&gt; setItems([&hellip;items, &hellip;newItems]));<br>\n};<\/p>\n<p>useEffect(() =&gt; {<br>\nfetchData();<br>\n}, [page]);<\/p>\n<\/div><\/div><h3 id=\"define-native-modules\">26. What are native modules in React Native, and why are they used?<\/h3><p><strong>Answer:<\/strong><\/p><p>Native modules are custom modules written in native code (Java\/Objective-C\/Swift) that extend React Native&rsquo;s functionality, allowing you to access platform-specific APIs.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { NativeModules } from &lsquo;react-native&rsquo;;<br>\nconst { MyNativeModule } = NativeModules;<\/p>\n<\/div><\/div><h3 id=\"bridge-native-module\">27. How do you bridge a native module to React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Create a native module in Java\/Objective-C\/Swift and expose it to React Native using the <strong>ReactMethod<\/strong> annotation (Android) or <strong>RCT_EXPORT_MODULE<\/strong> macro (iOS).<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>\/\/ Android example<br>\npackage com.myapp;<\/p>\n<p>import com.facebook.react.bridge.ReactApplicationContext;<br>\nimport com.facebook.react.bridge.ReactContextBaseJavaModule;<br>\nimport com.facebook.react.bridge.ReactMethod;<br>\nimport com.facebook.react.bridge.Promise;<\/p>\n<p>public class MyModule extends ReactContextBaseJavaModule {<br>\n@Override<br>\npublic String getName() {<br>\nreturn &ldquo;MyModule&rdquo;;<br>\n}<\/p>\n<p>@ReactMethod<br>\npublic void doSomething(Promise promise) {<br>\npromise.resolve(&ldquo;Success&rdquo;);<br>\n}<br>\n}<\/p>\n<\/div><\/div><h3 id=\"call-native-methods\">28. How do you call a native method from React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Call a native method using <strong>NativeModules<\/strong> after importing it into your React Native component.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { NativeModules } from &lsquo;react-native&rsquo;;<br>\nconst { MyModule } = NativeModules;<\/p>\n<p>MyModule.doSomething()<br>\n.then(result =&gt; console.log(result))<br>\n.catch(error =&gt; console.error(error));<\/p>\n<\/div><\/div><h3 id=\"manage-app-permissions\">29. How do you handle permissions in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>PermissionsAndroid<\/strong> module on Android or the <strong>react-native-permissions<\/strong> library to request and check permissions.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { PermissionsAndroid } from &lsquo;react-native&rsquo;;<\/p>\n<p>const requestCameraPermission = async () =&gt; {<br>\ntry {<br>\nconst granted = await PermissionsAndroid.request(<br>\nPermissionsAndroid.PERMISSIONS.CAMERA,<br>\n{<br>\ntitle: &ldquo;Camera Permission&rdquo;,<br>\nmessage: &ldquo;App needs camera access&rdquo;,<br>\nbuttonNeutral: &ldquo;Ask Me Later&rdquo;,<br>\nbuttonNegative: &ldquo;Cancel&rdquo;,<br>\nbuttonPositive: &ldquo;OK&rdquo;<br>\n}<br>\n);<br>\nif (granted === PermissionsAndroid.RESULTS.GRANTED) {<br>\nconsole.log(&ldquo;You can use the camera&rdquo;);<br>\n} else {<br>\nconsole.log(&ldquo;Camera permission denied&rdquo;);<br>\n}<br>\n} catch (err) {<br>\nconsole.warn(err);<br>\n}<br>\n};<\/p>\n<\/div><\/div><h3 id=\"integrate-native-libraries\">30. How do you integrate third-party native libraries in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Integrate third-party native libraries by linking them using <strong>react-native link<\/strong> (for older versions) or using the<strong> pod install<\/strong> command for iOS and manual linking for Android.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>npm install react-native-device-info<br>\ncd ios<br>\npod install<\/p>\n<\/div><\/div><h3 id=\"global-theming-setup\">31. How do you implement global theming in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>Context API<\/strong> or a theming library like <strong>styled-components<\/strong> to manage global themes across the app.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { ThemeProvider } from &lsquo;styled-components&rsquo;;<\/p>\n<p>const theme = {<br>\ncolors: {<br>\nprimary: &lsquo;#3498db&rsquo;,<br>\nsecondary: &lsquo;#2ecc71&rsquo;,<br>\n},<br>\n};<\/p>\n<p>const App = () =&gt; (<br>\n&lt;ThemeProvider theme={theme}&gt;<br>\n&lt;MyComponent \/&gt;<br>\n&lt;\/ThemeProvider&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"create-responsive-layouts\">32. How do you create responsive layouts in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use <strong>Dimensions<\/strong>, <strong>flexbox<\/strong>, or third-party libraries like <strong>react-native-responsive-screen<\/strong> to create responsive layouts.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { Dimensions, StyleSheet, View, Text } from &lsquo;react-native&rsquo;;<\/p>\n<p>const { width, height } = Dimensions.get(&lsquo;window&rsquo;);<\/p>\n<p>const styles = StyleSheet.create({<br>\ncontainer: {<br>\nwidth: width * 0.8,<br>\nheight: height * 0.5,<br>\nbackgroundColor: &lsquo;lightgray&rsquo;,<br>\n},<br>\n});<\/p>\n<p>const App = () =&gt; (<br>\n&lt;View style={styles.container}&gt;<br>\n&lt;Text&gt;Responsive Layout&lt;\/Text&gt;<br>\n&lt;\/View&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"platform-specific-styles\">33. How do you apply platform-specific styles in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>Platform<\/strong> module to apply platform-specific styles in your React Native components.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { Platform, StyleSheet, View, Text } from &lsquo;react-native&rsquo;;<\/p>\n<p>const styles = StyleSheet.create({<br>\ntext: {<br>\n&hellip;Platform.select({<br>\nios: {<br>\nfontFamily: &lsquo;Avenir&rsquo;,<br>\nfontSize: 20,<br>\n},<br>\nandroid: {<br>\nfontFamily: &lsquo;Roboto&rsquo;,<br>\nfontSize: 18,<br>\n},<br>\n}),<br>\n},<br>\n});<\/p>\n<p>const App = () =&gt; (<br>\n&lt;View&gt;<br>\n&lt;Text style={styles.text}&gt;Platform-specific styles&lt;\/Text&gt;<br>\n&lt;\/View&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"flexbox-for-layout\">34. How do you use Flexbox for layout in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Flexbox is the primary layout system in React Native, allowing you to align and distribute space among items in a container.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const styles = StyleSheet.create({<br>\ncontainer: {<br>\nflex: 1,<br>\nflexDirection: &lsquo;row&rsquo;,<br>\njustifyContent: &lsquo;space-between&rsquo;,<br>\nalignItems: &lsquo;center&rsquo;,<br>\n},<br>\nbox: {<br>\nwidth: 50,<br>\nheight: 50,<br>\nbackgroundColor: &lsquo;blue&rsquo;,<br>\n},<br>\n});<\/p>\n<p>const App = () =&gt; (<br>\n&lt;View style={styles.container}&gt;<br>\n&lt;View style={styles.box} \/&gt;<br>\n&lt;View style={styles.box} \/&gt;<br>\n&lt;View style={styles.box} \/&gt;<br>\n&lt;\/View&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"implement-dark-mode\">35. How do you implement dark mode in a React Native app?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>useColorScheme<\/strong> hook or <strong>Appearance<\/strong> API to detect the system theme and apply dark mode styles accordingly.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { useColorScheme } from &lsquo;react-native&rsquo;;<\/p>\n<p>const App = () =&gt; {<br>\nconst scheme = useColorScheme();<\/p>\n<p>const backgroundColor = scheme === &lsquo;dark&rsquo; ? &lsquo;black&rsquo; : &lsquo;white&rsquo;;<br>\nconst textColor = scheme === &lsquo;dark&rsquo; ? &lsquo;white&rsquo; : &lsquo;black&rsquo;;<\/p>\n<p>return (<br>\n&lt;View style={{ backgroundColor, flex: 1 }}&gt;<br>\n&lt;Text style={{ color: textColor }}&gt;Hello, World!&lt;\/Text&gt;<br>\n&lt;\/View&gt;<br>\n);<br>\n};<\/p>\n<\/div><\/div><h3 id=\"create-simple-animations\">36. How do you create simple animations in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>Animated<\/strong> API to create simple animations by interpolating values and applying them to styles.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { Animated } from &lsquo;react-native&rsquo;;<\/p>\n<p>const App = () =&gt; {<br>\nconst fadeAnim = new Animated.Value(0);<\/p>\n<p>Animated.timing(fadeAnim, {<br>\ntoValue: 1,<br>\nduration: 1000,<br>\nuseNativeDriver: true,<br>\n}).start();<\/p>\n<p>return (<br>\n&lt;Animated.View style={{ opacity: fadeAnim }}&gt;<br>\n&lt;Text&gt;Fading in&lt;\/Text&gt;<br>\n&lt;\/Animated.View&gt;<br>\n);<br>\n};<\/p>\n<\/div><\/div><h3 id=\"loop-animation-creation\">37. How do you create a looping animation in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use <strong>Animated.loop()<\/strong> to create a looping animation that repeats indefinitely or a specified number of times.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const spinValue = new Animated.Value(0);<\/p>\n<p>Animated.loop(<br>\nAnimated.timing(spinValue, {<br>\ntoValue: 1,<br>\nduration: 2000,<br>\nuseNativeDriver: true,<br>\n})<br>\n).start();<\/p>\n<p>const spin = spinValue.interpolate({<br>\ninputRange: [0, 1],<br>\noutputRange: [&lsquo;0deg&rsquo;, &lsquo;360deg&rsquo;],<br>\n});<\/p>\n<p>return &lt;Animated.View style={{ transform: [{ rotate: spin }] }} \/&gt;;<\/p>\n<\/div><\/div><h3 id=\"stagger-animations\">38. How do you create staggered animations in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use <strong>Animated.stagger()<\/strong> to create a sequence of animations that start after a specified delay.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const fadeAnim1 = new Animated.Value(0);<br>\nconst fadeAnim2 = new Animated.Value(0);<\/p>\n<p>Animated.stagger(500, [<br>\nAnimated.timing(fadeAnim1, { toValue: 1, duration: 1000, useNativeDriver: true }),<br>\nAnimated.timing(fadeAnim2, { toValue: 1, duration: 1000, useNativeDriver: true }),<br>\n]).start();<\/p>\n<p>return (<br>\n&lt;View&gt;<br>\n&lt;Animated.View style={{ opacity: fadeAnim1 }} \/&gt;<br>\n&lt;Animated.View style={{ opacity: fadeAnim2 }} \/&gt;<br>\n&lt;\/View&gt;<br>\n);<\/p>\n<\/div><\/div><h3 id=\"animate-list-items\">39. How do you animate list items when they appear in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>LayoutAnimation<\/strong> module to animate changes in the layout, such as the insertion of new list items.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import { LayoutAnimation, UIManager, Platform, View, Button } from &lsquo;react-native&rsquo;;<\/p>\n<p>if (Platform.OS === &lsquo;android&rsquo;) {<br>\nUIManager.setLayoutAnimationEnabledExperimental &amp;&amp; UIManager.setLayoutAnimationEnabledExperimental(true);<br>\n}<\/p>\n<p>const App = () =&gt; {<br>\nconst [items, setItems] = useState([]);<\/p>\n<p>const addItem = () =&gt; {<br>\nLayoutAnimation.configureNext(LayoutAnimation.Presets.spring);<br>\nsetItems([&hellip;items, { id: items.length, name: `Item ${items.length}` }]);<br>\n};<\/p>\n<p>return (<br>\n&lt;View&gt;<br>\n{items.map(item =&gt; (<br>\n&lt;View key={item.id}&gt;<br>\n&lt;Text&gt;{item.name}&lt;\/Text&gt;<br>\n&lt;\/View&gt;<br>\n))}<br>\n&lt;Button title=&rdquo;Add Item&rdquo; onPress={addItem} \/&gt;<br>\n&lt;\/View&gt;<br>\n);<br>\n};<\/p>\n<\/div><\/div><h3 id=\"use-usenativedriver-option\">40. How do you use the useNativeDriver option in React Native animations?<\/h3><p><strong>Answer:<\/strong><\/p><p>The <strong>useNativeDriver<\/strong> option allows animations to run on the native thread for better performance, but it only works with properties like opacity and transforms.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>Animated.timing(fadeAnim, {<br>\ntoValue: 1,<br>\nduration: 1000,<br>\nuseNativeDriver: true, \/\/ Enable native driver<br>\n}).start();<\/p>\n<\/div><\/div><h3 id=\"write-unit-tests\">41. How do you write unit tests for React Native components?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use the <strong>Jest<\/strong> testing framework and <strong>react-test-renderer<\/strong> to write unit tests for React Native components.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import React from &lsquo;react&rsquo;;<br>\nimport renderer from &lsquo;react-test-renderer&rsquo;;<br>\nimport MyComponent from &lsquo;..\/MyComponent&rsquo;;<\/p>\n<p>test(&lsquo;renders correctly&rsquo;, () =&gt; {<br>\nconst tree = renderer.create(&lt;MyComponent \/&gt;).toJSON();<br>\nexpect(tree).toMatchSnapshot();<br>\n});<\/p>\n<\/div><\/div><h3 id=\"perform-snapshot-testing\">42. How do you perform snapshot testing in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Snapshot testing involves rendering a component and saving its output to a file, which is then compared with future renders to ensure consistency.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import renderer from &lsquo;react-test-renderer&rsquo;;<\/p>\n<p>test(&lsquo;MyComponent renders correctly&rsquo;, () =&gt; {<br>\nconst tree = renderer.create(&lt;MyComponent \/&gt;).toJSON();<br>\nexpect(tree).toMatchSnapshot();<br>\n});<\/p>\n<\/div><\/div><h3 id=\"mock-api-calls\">43. How do you mock API calls in React Native tests?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use <strong>jest.mock<\/strong> to mock API calls in your tests, ensuring that tests run without making actual network requests.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>jest.mock(&lsquo;axios&rsquo;);<\/p>\n<p>test(&lsquo;fetches data successfully&rsquo;, async () =&gt; {<br>\naxios.get.mockResolvedValue({ data: { id: 1, name: &lsquo;John Doe&rsquo; } });<br>\nconst data = await fetchData();<br>\nexpect(data.name).toBe(&lsquo;John Doe&rsquo;);<br>\n});<\/p>\n<\/div><\/div><h3 id=\"test-asynchronous-code\">44. How do you test asynchronous code in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use <strong>async\/await<\/strong> in your tests to handle asynchronous operations and make assertions after the async code has run.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>test(&lsquo;async function returns data&rsquo;, async () =&gt; {<br>\nconst data = await asyncFunction();<br>\nexpect(data).toBe(&lsquo;expectedData&rsquo;);<br>\n});<\/p>\n<\/div><\/div><h3 id=\"perform-e2e-testing\">45. How do you perform end-to-end (E2E) testing in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use tools like <strong>Detox<\/strong> to perform end-to-end testing by simulating user interactions and validating app behavior.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>detox init -r jest<br>\ndetox test<\/p>\n<\/div><\/div><h3 id=\"avoid-re-renders\">46. How do you optimize React Native performance by avoiding unnecessary re-renders?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use <strong>React.memo<\/strong> for functional components and <strong>PureComponent<\/strong> for class components to prevent unnecessary re-renders.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>const MyComponent = React.memo(({ prop1 }) =&gt; {<br>\nreturn &lt;Text&gt;{prop1}&lt;\/Text&gt;;<br>\n});<\/p>\n<\/div><\/div><h3 id=\"improve-large-lists\">47. How do you improve the performance of large lists in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Use <strong>FlatList<\/strong> or <strong>SectionList<\/strong> with optimizations like <strong>getItemLayout<\/strong>, <strong>initialNumToRender<\/strong>, and <strong>removeClippedSubviews<\/strong>.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>&lt;FlatList<br>\ndata={data}<br>\nrenderItem={renderItem}<br>\nkeyExtractor={item =&gt; item.id}<br>\ninitialNumToRender={10}<br>\ngetItemLayout={(data, index) =&gt; ({ length: ITEM_HEIGHT, offset: ITEM_HEIGHT * index, index })}<br>\nremoveClippedSubviews={true}<br>\n\/&gt;<\/p>\n<\/div><\/div><h3 id=\"reduce-app-size\">48. How do you reduce the app bundle size in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Reduce app bundle size by enabling <strong>Proguard<\/strong> for Android, using <strong>Hermes<\/strong> engine, and removing unused dependencies.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>\/\/ Enable Hermes in android\/app\/build.gradle<br>\nproject.ext.react = [<br>\nenableHermes: true<br>\n]\n<\/p><\/div><\/div><h3 id=\"optimize-image-loading\">49. How do you optimize image loading in React Native?<\/h3><p><strong>Answer:<\/strong><\/p><p>Optimize images by using appropriate formats, compressing images, and using tools like <strong>react-native-fast-image<\/strong> for better performance.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>import FastImage from &lsquo;react-native-fast-image&rsquo;;<\/p>\n<p>&lt;FastImage<br>\nstyle={{ width: 200, height: 200 }}<br>\nsource={{<br>\nuri: &lsquo;https:\/\/example.com\/image.png&rsquo;,<br>\npriority: FastImage.priority.high,<br>\n}}<br>\nresizeMode={FastImage.resizeMode.cover}<br>\n\/&gt;<\/p>\n<\/div><\/div><h3 id=\"avoid-memory-leaks\">50. How do you handle memory leaks in React Native applications?<\/h3><p><strong>Answer:<\/strong><\/p><p>Handle memory leaks by unmounting components properly, cleaning up event listeners, and avoiding long-running timers.<\/p><div class=\"su-note\" style=\"border-color:#e5dbc7;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\"><div class=\"su-note-inner su-u-clearfix su-u-trim\" style=\"background-color:#FFF5E1;border-color:#ffffff;color:#333333;border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;\">\n<p>useEffect(() =&gt; {<br>\nconst timer = setInterval(() =&gt; {<br>\nconsole.log(&lsquo;Interval running&rsquo;);<br>\n}, 1000);<\/p>\n<p>return () =&gt; clearInterval(timer); \/\/ Cleanup<br>\n}, []);<\/p>\n<\/div><\/div><h2>Final Words<\/h2><p>Getting ready for an interview can feel overwhelming, but going through these React Native fresher interview questions can help you feel more confident. This guide focuses on the kinds of React Native-related interview questions for fresher roles that you&rsquo;re likely to face.<\/p><p>Don&rsquo;t forget to practice the React Native basics, component lifecycle, and state management-related interview questions too! With the right preparation, you&rsquo;ll ace your React Native interview and take that important step in your career.<\/p><hr><h2>Frequently Asked Questions<\/h2><h3>1. What are the most common interview questions for React Native?<\/h3><p>The most common interview questions for React Native often cover topics like component lifecycle, state and props, navigation, and styling with React Native&rsquo;s styling system.<\/p><h3>2. What are the important React Native topics freshers should focus on for interviews?<\/h3><p>The important React Native topics freshers should focus on include understanding components, handling state and props, navigation with React Navigation, and integrating with native modules.<\/p><h3>3. How should freshers prepare for React Native technical interviews?<\/h3><p>Freshers should prepare for React Native technical interviews by building sample apps, practicing common UI challenges, and understanding the differences between React and React Native.<\/p><h3>4. What strategies can freshers use to solve React Native coding questions during interviews?<\/h3><p>Strategies freshers can use include breaking down the problem, efficiently managing state, and testing components to ensure they render correctly on different devices.<\/p><h3>5. Should freshers prepare for advanced React Native topics in interviews?<\/h3><p>Yes, freshers should prepare for advanced React Native topics like performance optimization, handling animations, and integrating with native APIs if the role requires a deeper understanding of React Native.<\/p><hr><h2>Explore More React Native Resources<\/h2><ul class=\"explore-more\">\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/react-native-project-ideas-for-beginners\/\">React Native Project Ideas<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/react-native-ides-and-code-editors\/\">React Native IDEs<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/react-vs-react-native\/\">React vs React Native<\/a><\/li>\n<\/ul><h2>Explore More Interview Questions<\/h2><ul class=\"explore-more\">\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/python-interview-questions-for-freshers\/\">Python<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/java-interview-questions-for-freshers\/\">Java<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/sql-interview-questions-for-freshers\/\">SQL<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/react-interview-questions-for-freshers\/\">React<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/javascript-interview-questions-for-freshers\/\">JavaScript<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/c-programming-interview-questions-for-freshers\/\">C Programming<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/html-interview-questions-for-freshers\/\">HTML<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/css-interview-questions-for-freshers\/\">CSS<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/angular-interview-questions-for-freshers\/\">Angular<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/cpp-interview-questions-for-freshers\/\">C++<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/spring-boot-interview-questions-for-freshers\/\">Spring Boot<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/node-js-interview-questions-for-freshers\/\">Node JS<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/excel-interview-questions-for-freshers\/\">Excel<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/c-sharp-interview-questions-for-freshers\/\">C#<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/dbms-interview-questions-for-freshers\/\">DBMS<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/php-interview-questions-for-freshers\/\">PHP<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/linux-interview-questions-for-freshers\/\">Linux<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/operating-system-interview-questions-for-freshers\/\">Operating System<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/mysql-interview-questions-for-freshers\/\">MySQL<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/spring-interview-questions-for-freshers\/\">Spring<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/flutter-interview-questions-for-freshers\/\">Flutter<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/mongodb-interview-questions-for-freshers\/\">MongoDB<\/a><\/li>\n<li><a href=\"https:\/\/www.placementpreparation.io\/blog\/django-interview-questions-for-freshers\/\">Django<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Are you preparing for your first React Native interview and wondering what questions you might face? Understanding the key React Native interview questions for freshers can give you more clarity.This blog is here to help you get ready with practical questions that test your real-world problem-solving skills. We&rsquo;ve gathered some of the most common basic [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":12539,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[45],"tags":[],"class_list":["post-12536","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-interview-questions"],"_links":{"self":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts\/12536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/comments?post=12536"}],"version-history":[{"count":7,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts\/12536\/revisions"}],"predecessor-version":[{"id":14873,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/posts\/12536\/revisions\/14873"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/media\/12539"}],"wp:attachment":[{"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/media?parent=12536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/categories?post=12536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.placementpreparation.io\/blog\/wp-json\/wp\/v2\/tags?post=12536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}