Test your understanding of core React Native concepts and interview topics with this 15-question multiple-choice quiz. Topics include state, props, hooks, navigation, lists, layout techniques, and common components used in React Native development.
Which of the following best describes React Native?
Explanation: React Native is an open-source framework that enables developers to build mobile apps using JavaScript and React. It bridges JavaScript with native mobile components. The other options refer either to web or desktop technologies, or backend frameworks, which are not related to React Native's focus.
How does React Native differ from ReactJS when rendering user interfaces?
Explanation: React Native targets mobile platforms by mapping components to native UI elements, while ReactJS is meant for web apps rendered in browsers using HTML and CSS. The other options misrepresent platforms or the rendering process in both frameworks.
Which React Native component is typically used to display editable text input fields?
Explanation: TextInput is specifically designed for entering and editing text in React Native. Image is for displaying images, TouchableHighlight is for pressable elements, and View is a container for layout purposes but not for text input.
What is the main purpose of JSX in React Native development?
Explanation: JSX stands for JavaScript XML and lets developers write code similar to HTML within JavaScript, which is then converted into native components. It does not deal with HTTP requests, data encryption, or navigation directly.
In React Native, what is the primary use of state within a component?
Explanation: State is used for dynamic data that affects rendering. Props are for passing data from parent to child, navigation is typically handled with routers or libraries, and constants should not be stored in state.
What is a key difference between props and state in React Native?
Explanation: Props are external and read-only, allowing data flow from parent to child; state is internal and meant for a component's own data. Props do not mutate nor manage storage or global visibility, which the other options incorrectly state.
What does the useEffect hook enable you to do in a functional component?
Explanation: useEffect is intended for handling side effects such as API calls, timers, or subscriptions after component render. It does not directly update state, handle navigation, or define global constants.
What is a typical method for navigating to another screen in a React Native app?
Explanation: Navigation libraries provide the navigation.navigate method for screen transitions. setState does not handle navigation, localStorage is not for screen logic, and direct imports do not handle navigation context.
Why is FlatList recommended over ScrollView for long lists in React Native?
Explanation: FlatList optimizes resource usage by rendering only visible list items, making it suitable for large lists. ScrollView renders all child elements at once and is not as efficient. FlatList supports vertical and horizontal scrolling, and ScrollView is less memory efficient as it mounts all children.
How does Flexbox help when designing layouts in React Native?
Explanation: Flexbox in React Native helps align and distribute space efficiently, allowing responsive layouts. It does not fetch data, manage storage, or handle encryption, which are unrelated to layout design.
What is AsyncStorage primarily used for in React Native?
Explanation: AsyncStorage lets you store simple data like user tokens or preferences. It's not meant for large files, navigation persistence, or running background jobs.
What feature does TouchableOpacity provide for React Native interfaces?
Explanation: TouchableOpacity visually indicates user interaction by changing opacity, enhancing user experience for pressable elements. It doesn't handle encryption, data loading, or permissions.
Why would you use SafeAreaView in a React Native project?
Explanation: SafeAreaView ensures the app's content is rendered within safe screen boundaries, avoiding overlaps with notches or system UI. Other options do not relate to UI layout or safe areas.
What is a key distinction between a class component and a functional component in React Native?
Explanation: Class components utilize lifecycle methods, while functional components use hooks for state and side effects. Functional components can render UI and handle input, and their use isn't limited to web development.
For what purpose is the useRef hook typically used in React Native?
Explanation: useRef enables you to maintain references that persist across rerenders and don't cause rerenders if changed. It’s not for fetching data, navigation, or stateful rerendering.
How are forms commonly handled in React Native?
Explanation: Form inputs are managed by controlling their value with state hooks like useState. Direct DOM manipulation is not part of React Native, values aren’t typically stored directly in localStorage, and relying only on props doesn't support input state changes.