React Native is an open-source mobile application framework created by Facebook, Inc. It is used to develop applications for Android, iOS, macOS, Web, and Windows by enabling developers to use React's framework along with native platform capabilities. Follow along and check our list of essential React Native interview questions and answers that will trend on mobile developers interviews in 2021.
You can also find all 72 answers here ππΌ https://devinterview.io/dev/reactNative-interview-questions
- Native mobile apps are the most common type of app.
- They are built for specific platforms and are written in languages that the platform accepts. For example,
Swiftand Objective-C for native iOS apps andJavaorKotlinfor native Android apps. - Native apps are also built using the specific Integrated Development Environment (IDE) for the selected operating systems
Some benefits of React Native are:
- Known for Optimal Performance
- Can Reuse the Codes and Pre-Developed Components
- Large Community of Developers
- Advantage of Live and Hot Reloading
- Cost Effective Solution
- Offers Simple User Interface
- Support for Third-Party Plugins
- Modular Architecture
- Providing Handy Solutions and Libraries
Consider:
import { Text, StyleSheet } from "react-native";Curly braces are used to import small pieces of library. In above example we just want to make use of Text and StyleSheet component from react-native, so they are put in curly braces.
- Works across multiple platforms.
- Unified development.
- Faster build and lower cost of development.
- Easier to make changes and update.
- Hybrid mobile apps are applications that are installed on a device, just like any other app.
- Hybrid apps are deployed in a native container that uses a mobile
WebViewobject. When the app is used, this object displays web content thanks to the use of web technologies (CSS,JavaScript,HTML).
React Nativeis a mobile app development framework that enables the development of multi-platform Android and iOS apps using native UI elements.- It is based on the JavaScriptCore runtime and Babel transformers. With this setup react native supports new
JavaScript(ES6+) features, e.g. arrow functions, async/await etc. - This famous framework for mobile app development started in the summer of 2013 as Facebookβs internal hackathon project.
- Its first public preview was released in January of 2015 at
ReactjsConference and in March of 2015, Facebook made React Native open and available on GitHub.
Using Keyboard.dismiss()
import { Keyboard } from 'react-native'
// Hiding the keyboard Keyboard.dismiss()
- JSX is an XML/HTML-like syntax used by
Reactthat extends ECMAScript so that XML/HTML-like text can co-exist withJavaScript/Reactcode. - The syntax is intended to be used by preprocessors (i.e., transpilers like Babel) to transform HTML-like text found in
JavaScriptfiles into standard JavaScript objects that a JavaScript engine will parse.
const nav = ( <ul id="nav"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Clients</a></li> <li><a href="#">Contact Us</a></li> </ul> );- The properties of React Native components are simply pronounced as props.
- In React Native, most of the components can be customized at the time of their creation with different parameters. These parameters are known as props.
- They are immutable, and they cannot be changed.
import React, { Component } from 'react';
import {
Platform,
StyleSheet,
Image,
Text,
View
} from 'react-native';export default class App extends Component<{}> {
render() {
let imagePath = { uri: 'https://facebook.github.io/react-native/img/header_logo.png'};
return (
<View style={styles.container}>
<Text style={styles.welcome}>Welcome to React Native!</Text>
<Image source={imagePath} style={{width: 250, height: 250}} />
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#a7a6a9',
},
welcome: {
fontSize: 30,
textAlign: 'center',
margin: 20,
}
});
Output
Some popular options are:
- Async Storage ("built-in" to React Native)
- SQLite
- Realm
- Firebase
- MongoDB
<View> <Text>Hey there!</Text> <Text style={{ fontsize: 40 }} >Example of inline style</Text>; </View>No. An error will be thrown as Text strings must be rendered within Text component. Because here semi-colon in third line will be treated as text, and in React native all texts needs to be rendered inside Text tag.
- They work efficiently as they are built for that specific platforms
- Native apps are responsive on all the platform-specific devices
- They are very fast and the best in the app performance
- Native apps better integrate with mobile hardware
- They have interactive and intuitive User Interface (UI) and User Experience (UX) as per the user expectations based on specific platforms
- Some of the Native mobile apps work even without the Internet connection
- Native apps are secured and reliable
- They can easily access or utilize the other device-specific capabilities like GPS, Camera, Contacts, etc.
- There are two types of data that control a component:
propsandstate. propsare set by the parent and they are fixed throughout the lifetime of a component. For data that is going to change, we have to usestate.
The gesture responder system manages the lifecycle of gestures in an app.