I C React Native Developer
I C React Native Developer
https://prepflix.in/questions/infosys
Reena installed ionic native, but she is getting the following error while trying to preview the application over browser:
Native: tried calling Statusbar.styleDefault, but cordova is not available
How can this be resolved?
Option A
Option B
Option C
Option D
Correct Answer a
Which statements from below are TRUE about keys in React. Select all options that are applicable.
Option A Keys are used to identify unique Virtual DOM elements that are driving the UI.
Option B Keys are optional attribute in components.
Option C Since it is optional attribute in components React will not throw any warning for it and thus it is good to ignore adding any keys in JSX.
Option D Keys can be given any values like unique number or string, thus I can provide timestamp as a value to keys attribute.
Correct Answer abe
Alex wants to build a native mobile application. He wants to use React Native to code the application. Select the appropriate option from below:
Option A Same code will work on all OS
Option B Same code will work only on Android and iOS
Option C Have to code separately for each mobile OS
Option D Can only create Android apps using React Native
Correct Answer b
Dom wants to create a mobile banking application which needs to be highly secure. Which of the following would you normally chose to build it?
If React Native is creating pure native app and the built app (i.e, .apk, or .ipa) has javascript bundle in it , then how is the app a pure native app. Identify the CORRECT statement from below.
Option A React native doesn’t create a pure native app. It runs the bundles javascript bundle in the webview of the native platfrom. Thus it is just wrapping the javascript in a native executable container
Option B React native compiles and builds the javascript into native components, and thus the end ipa or apk doesn’t contain the bundle file rather the it contains the native corresponding code , ie. Objective-
c / swift code or java code in case of Android
Option C
React native uses the React Native’s Bridge layer to serialize,batch commands for native layer, for the javascript implemented components. It uses the javascript runtime provided by the native platform to do it without blocking the U
Option D React Native uses internally Apache cordova to create native app (i.e apk, ipa )
Correct Answer c
Option A The code will execute without any errors and both statements will be displayed in the same row as two coloumns
Option B The code will execute without any errors and both statements will be displayed in the different rows
Option C The code will execute without any errors but only the first statement will be displayed
Option D The code will run into errors
Correct Answer a
Option A
Ref is added to the DOM element or an instance of a component to access it directly. It takes function as value which will receive the underlying DOM element or the mounted instance of the component as its first argument..
Option B Ref is only available in React.js and not in React-Native.
Option C Ref cannot be applied to the React Native’s core components.
Option D Ref is a way to access DOM element or instance of a component. It can be assigned a javascript object which the element can access as well.
Correct Answer a
Option A This method ensures that the style values created are immutable and opaque and they are only created once
Option B Stylesheet.create is method that can implement a function which takes javascript object as argument for the function
Option C Stylesheet.create method is very performance intensive operation and should be used carefully
Option D Stylesheet is imported from react package which also works well with React Native
Correct Answer a
const rows = [
{id: '0', text: 'Item 1'},
{id: '1', text: 'Item 2'},
{id: '2', text: 'Item 3'},
{id: '3', text: 'Item 4'},
{id: '4', text: 'Item 5'},
{id: '5', text: 'Item 6'},
{id: '6', text: 'Item 7'},
{id: '7', text: 'Item 8'},
{id: '8', text: 'Item 9'},
{id: '9', text: 'Item 10'},
{id: '10', text: 'Item 11'},
{id: '11', text: 'Item 12'},
{id: '12', text: 'Item 13'},
{id: '13', text: 'Item 14'},
{id: '14', text: 'Item 15'}
]
render() {
return (
<FlatList
style={styles.container}
renderItem={this.renderItem}
/>
);
}
}
Option A
Option B
Add data={rows} to FlatList tag inside render() to get the expected result
Option C
Add data={rows} to Text tag inside renderItem to get the expected result
Option D
Correct Answer b
Observe the following code. Which among the options is true if you want to replace the "<placeholder>":
Option A
{
margin: 24,
font-size: 18,
font-weight: 'bold',
text-align: 'center',
background-color:blue
}
Option B {
margin: 24,
fontsize: 18,
fontweight: 'bold',
textalign: 'center',
backgroundcolor:blue
}
Option C {
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
backgroundColor:'blue'
}
Option D {
margin: 24,
fontSize: 18,
fontWeight: 'bold',
textAlign: 'center',
bgColor:'blue'
}
Correct Answer c
Jack wants to create a model for his application. He wants the elements to be scrollable horizontally. What modification (if any) should he do to the following code for this purpose:
George Wants to display a list of names using FlatList. He wrote the below code. Predict the behavior of the same when he tries to run it
Which of these is/are TRUE with respect to styling a React Native component.
Option A All core components provided by React Native accepts a prop called ‘style’
Option B In React Native styling is achieved using Javascript
Option C Style name and values usually match how css work on web, except name are written in camel-case
Option D
The style prop only accepts a JS object, we cannot pass an array of styles to this prop
Oliver wants to create a mobile application using React Native. He wants to add routing to his application. He is a bit confused regarding the swipe and animation properties of his code and decided to consult with you.
Go through the code and choose the most appropriate option.
Option A Both swipe and animation during the swipe will be enabled by default
Option B Both swipe and animation will be disabled by default
Option C Swipe will be enabled by default but animation during the swipe should be enabled by setting animationEnabled property in createMaterialTopTabNavigator to true
Option D Animation will be enabled by default but swipe should be enabled by setting swipeEnabled property in createMaterialTopTabNavigator to true
Correct Answer a
Tyson wanted to create a rest call in react native. Observe the following code and choose the appropriate output.
(Assume "https://jsonplaceholder.typicode.com/comments" will return a list of objects in which email is a property of each object)
constructor(props){
super(props);
this.state ={ isLoading: true}
}
componentDidMount(){
return fetch('https://jsonplaceholder.typicode.com/comments').toObservable()
.subscribe((response) => response.json())
.subscribe((responseJson) => {
this.setState({
isLoading: false,
dataSource: responseJson,
}, function(){
});
})
}
render(){
if(this.state.isLoading){
return(
<View style={{flex: 1, padding: 20}}>
<ActivityIndicator/>
</View>
)
}
return(
<View style={{flex: 1, paddingTop:20}}>
<FlatList
data={this.state.dataSource}
renderItem={({item}) => <Text>{item.email}</Text>}
keyExtractor={({id}, index) => id}
/>
</View>
);
}
}
Which of the following is/are the CORRECT ways to manage data in React Native?
Option A using AsyncStorage
Option B using Redux
Option C using State
Option D using props
Correct Answer abcd
Is it possible to combine the native ios and native android code in React Native?
Which all statements are CORRECT from implementation perspective of Higher Order Components?
TextInput is one of the core component used for inputing text into app via a keyboard. This component takes 2 important props ‘onChange’ and ‘onChangeText’. Which of these statements is/are TRUE for these 2 props.
Option A Both of these props takes value as functions.
Option B
The callback on onChangeText is called when the text input's text changes. Changed text is passed as an argument to the callback handler. Whereas in onChange Callback that is called when the text input's text changes but no va
Option C There is no ‘onChangeText’ prop for TextInput component. Only ‘onChange’ prop is available.
Option D Both these props are available but ‘onChangeText’ is used only for ios platform and ‘onChange’ is used for Android paltfrom.
Correct Answer ab
What are the benefits of developing app using React Native over pure native development?
It is a framework to build cross-platform application with almost the same code base
Choose the best option for <Placeholder A>, <Placeholder B>, <Placeholder C> so that the child views are displayed as vertical stripes, with equal space between each other and screen border, and spread from top to bottom
of the screen. Assume all the imports are properly done.
Option A
Option B
Option C
Option D
Correct Answer a
Which of the foloowing is the event that tracks change in Switch value?
Option A onValueChange
Option B onSwitchChange
Option C onDataChange
Option D onToggle
Correct Answer a
Assuming all the imports are properly done, choose the best option to run this application.
onChange(value){
this.setState({
name: value
})
}
render() {
return (
<View style={styles.container}>
<Placeholder A>
style={{height: 40}}
placeholder='Enter Name'
value={this.state.name}
<Placeholder B> = {(value) => this.onChange(value)}
/>
<Text style={styles.paragraph}>Hello {this.state.name}</Text>
</View>
);
}
}
Option A
Option B
Option C
Option D
Correct Answer c
Select the libraries which I can use for Networking needs of my React Native apps
Option A Fetch Api
Option B ES2017 proposed async/await
Option C XMLHttpRequest API
Option D Third party libraries like axios
Correct Answer e
Which of the following mobile app development approaches needs multiple codebases for different platforms?
Option A native
Option B hybrid
Option C mobile web
Option D MADP
Correct Answer a
Manu was trying to add styles to his React Native Project. Choose the appropriate option from below
var styles={};
export default class LotsOfStyles extends Component {
styles= StyleSheet.create({
color: {
padding:40,
color: 'red',
},
});
render() {
return (
<View>
<Text style={styles.color}>This is a test statement</Text>
</View>
);
}
}
Observe the following code and choose the most appropriate option.
render() {
return <Placeholder text="Home Component!" />;
}
}
render() {
return <Placeholder text="Products Component!" />;
}
}
Option A
Will run without errors and the tabs created will have the label "HomeStack" and "ProductStack"
Option B
Will run without errors and the tabs created will have the label "Home!" and "Products!"
Option C
Will run without errors and the tabs created will have the label "Home Component!" and "Products Component!"
Option D
Correct Answer a
Which if the below files is the entry point for react native apps created using react-native-cli?
Option A index.js
Option B App.js
Option C .watchmanconfig
Option D app.json
Correct Answer a
});
Arjun was trying the flex property of React Native. He wrote the following code and tried to execute it.
Option A The code will execute without any errors and both statements will be displayed
Option B The code will execute without any errors but only the first statement will be displayed
Option C The code will execute without any errors but only the second statement will be displayed
Option D The code will run into errors
Correct Answer b
Ray wants to create a rough layout using flex boxes in React Native. He wants a header on the top and a footer at the bottom. There should be two columns for writing the contents in between the header and the footer.
Choose the most appropriate option.
Option A
Option B
Option C
Option D
Correct Answer d
Zack wanted to create a sectionList for displaying his list of alterEgos using React Native. Choose the appropriate outcome you think the below code will result in
const myList = [
{
title: 'Male',
data: ['Bruce Wayne', 'Clark Kent', 'Barry Allen'],
},
{
title: 'Female',
data: ['Diana Prince', 'Mira'],
},
];
const renderMyItems = ({ item }) => {
return <Text style={styles.item}>{item}</Text>;
};
const renderMySections = ({ section }) => {
return <Text style={styles.sectionHeader}>{section.title}</Text>;
};
const myKeys = (item, index) => {
return index;
};
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 22,
},
sectionHeader: {
paddingTop: 2,
paddingLeft: 10,
paddingRight: 10,
paddingBottom: 2,
fontSize: 14,
fontWeight: 'bold',
backgroundColor: 'rgba(247,247,247,1.0)',
},
item: {
padding: 10,
fontSize: 18,
height: 44,
},
});
Option A The code will run without errors and he will get the expected list as the output
Option B The code will run without errors but he will get a blank page
Option C The code will result in error
Option D The code will run without errors and he will get only the first value as the output
Correct Answer a
Mr.Wayne wanted to create a react native application. He wants to apply a border as well as a text color to a particular text. Below is the code he used for the same. Select the most appropriate result,
you think, he would end up with:
styles = StyleSheet.create({
color: {
color: 'blue',
padding: 30,
marginTop: 30,
borderRadius: 4,
borderWidth: 0.5,
borderColor: 'black',
},
});
Option A
Redux state is single of truth. State is read-only. Changes to redux state are made only through pure functions.
Option B Redux state are mutable object. Changes to redux state is made through reducer functions.
Option C Only Reducer can update the state of Redux. Reducer updates the state properties and returns the same state object.
Option D State in redux is an immutable javascript object with helper methods such as dispatch, subscribe available on it.
Correct Answer ad