InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
List down Key Points to integrate React Native in an existing Android mobile application |
|
Answer» Primary points to note to integrating React Native COMPONENTS into your Android application are to:
|
|
| 2. |
Describing Networking in React Native and how to make AJAX network calls in React Native? |
|
Answer» React Native provides the Fetch API for networking needs. Networking is an inherently ASYNCHRONOUS operation. Fetch methods will return a Promise that makes it straightforward to write CODE that works in an asynchronous manner: const getMoviesFromApi = () => { return fetch('https://reactnative.dev/movies.json') .then((response) => response.json()) .then((json) => { return json.movies; }) .catch((error) => { console.error(error); });};The XMLHttpRequest API is built in to React Native Since frisbee and Axios use XMLHttpRequest we can even use these libraries. var request = NEW XMLHttpRequest();request.onreadystatechange = (e) => { if (request.readyState !== 4) { return; } if (request.status === 200) { console.log('success', request.responseText); } else { console.warn('error'); }};request.open('GET', 'https://mywebsite.com/endpoint/');request.send(); |
|
| 3. |
What is Props Drilling and how can we avoid it ? |
|
Answer» PROPS Drilling (Threading) is a concept that refers to the process you pass the DATA from the parent component to the exact child Component BUT in between, other COMPONENTS owning the props just to pass it down the chain. Steps to avoid it 1. React Context API. |
|
| 4. |
How to debug React Native Applications and Name the Tools used for it ? |
|
Answer» In the React Native world, debugging may be done in different ways and with different tools, since React Native is composed of different environments (iOS and Android), which means there’s an assortment of problems and a variety of tools needed for debugging.
React Native CLI You can use the React Native CLI to do some debugging as well. It can also be used for showing the logs of the app. Hitting react-native log-android will show you the logs of db logcat on Android, and to view the logs in iOS you can run react-native log-ios, and with console.log you can dispatch logs to the terminal: console.log("some error🛑") |
|
| 5. |
Describe Timers in React Native Application ? |
|
Answer» Timers are an important and integral part of any application and React Native implements the browser timers.
There may be business requirements to EXECUTE a certain PIECE of code after waiting for some time duration or after a delay setTimeout can be used in such cases, clearTimeout is simply used to CLEAR the timer that is started. setTimeout(() => {yourFunction();}, 3000);
setInterval is a method that calls a function or runs some code after specific intervals of time, as specified through the second parameter. setInterval(() => {console.log('INTERVAL triggered');}, 1000);A function or block of code that is bound to an interval EXECUTES until it is stopped. To stop an interval, we can use the clearInterval() method.
Calling the function or execution as soon as possible. var immediateID = setImmediate(function);// The below code displays the alert dialog immediately.var immediateId = setImmediate( () => { alert('Immediate Alert');}clearImmediate is used for Canceling the immediate actions that were set by setImmediate().
It is the standard way to perform animations. Calling a function to update an animation before the next animation frame. var requestID = requestAnimationFrame(function);// The following code performs the animation.var requestId = requestAnimationFrame( () => { // animate something})cancelAnimationFrame is used for Canceling the function that was set by requestAnimationFrame(). |
|
| 6. |
What is Redux in React Native and give important components of Redux used in React Native app ? |
|
Answer» Redux is a predictable state container for JavaScript apps. It helps write applications that run in different environments. This means the entire data flow of the app is handled WITHIN a SINGLE container while persisting previous state. Actions: are payloads of information that send data from your application to your store. They are the only source of information for the store. This means if any state change is necessary the change required will be DISPATCHED through the actions. |
|
| 7. |
What is State and how is it used in React Native? |
|
Answer» It is used to control the components. The VARIABLE data can be stored in the state. It is mutable MEANS a state can change the value at any time. import React, {Component} from 'react'; import { Text, View } from 'react-native'; export default class App extends Component { state = { myState: 'State of Text Component' }updateState = () => this.setState({myState: 'The state is updated'})RENDER() {return (<View> <Text onPress={this.updateState}> {this.state.myState} </Text> </View> ); } }Here we create a Text component with state data. The content of the Text component will be updated whenever we CLICK on it. The state is updated by event onPress . |
|
| 8. |
How is user Input Handled in React Native ? |
|
Answer» TextInput is a Core Component that allows the user to enter text. It has an onChangeText prop that takes a function to be called every TIME the text CHANGES, and an onSubmitEditing prop that takes a function to be called when the text is submitted. import REACT, { useState } from 'react';import { Text, TextInput, View } from 'react-native';const PizzaTranslator = () => { const [text, setText] = useState(''); return ( <View STYLE={{padding: 10}}> <TextInput style={{height: 40}} placeholder="Type here to TRANSLATE!" onChangeText={text => setText(text)} defaultValue={text} /> <Text style={{padding: 10, fontSize: 42}}> {text.split(' ').map((word) => word && '🍕').join(' ')} </Text> </View> );}export default PizzaTranslator; |
|
| 9. |
Are default props available in React Native and if yes for what are they used and how are they used ? |
|
Answer» Yes, default props available in REACT Native as they are for React, If for an INSTANCE we do not pass props value, the component will use the default props value. import React, {Component} from 'react'; import {View, TEXT} from 'react-native';class DefaultPropComponent EXTENDS Component { render() { return ( <View> <Text> {this.props.NAME} </Text> </View> ) }}Demo.defaultProps = { name: 'BOB'}export default DefaultPropComponent; |
|
| 10. |
What are threads in General ? and explain Different Threads in ReactNative with Use of Each ? |
|
Answer» The single sequential flow of control within a program can be controlled by a thread.
|
|
| 11. |
Describe advantages of using React Native? |
|
Answer» There are multiple ADVANTAGE of using React Native like,
|
|
| 12. |
What is Flexbox and describe any elaborate on its most used properties? |
||||||||||||
|
Answer» It is a layout MODEL that ALLOWS elements to align and distribute space within a container. With Flexbox when Using flexible widths and heights, all the inside the main container can be aligned to fill a space or distribute space between elements, which makes it a great tool to USE for responsive design systems.
|
|||||||||||||
| 13. |
How Different is React-native from ReactJS ? |
||||||||||||
Answer»
|
|||||||||||||