skip to content

Core UI Primitives

The built-in components every screen is built from: View and Text, TextInput, Image, Pressable, Modal and ScrollView. Interviewers start here to see whether you think in native views or in the DOM.

part ofReact Nativeoverview, primer and where to startread it →
on this pageshow

explore

questions

page 2 of 2

In a React Native listing gallery, how would you use Image.prefetch, Image.queryCache and Image.getSize so the next photo appears instantly at the right shape?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Prefetch the next one or two photos with Image.prefetch(url) so they are in the disk cache before the swipe, check what is already cached with Image.queryCache(urls), and use Image.getSize only when the API gives no aspect ratio, since it may download the image.

open as a page

On a notched phone, a React Native chat composer under a header is partly hidden by the keyboard or leaves a gap above it; how do you diagnose and fix it?

level: seniorimportance: should knowfreq 32%

basics

~20 s

Measure the error. Hidden by the header height means keyboardVerticalOffset is missing; a gap equal to the bottom safe-area inset means that inset padding stays while the keyboard is open. Android 15+ edge-to-edge problems before 0.86 need the upgrade.

open as a page

In a React Native photo-backup app, why can a confirm-delete Modal flash blank or crash on iOS while closing, but not on Android, and how do you fix it?

level: seniorimportance: should knowfreq 18%

basics

~20 s

On iOS a React Native Modal keeps rendering its children until the native dismissal finishes and onDismiss fires; Android stops at once. Clearing the selected photo alongside visible={false} re-renders the closing iOS dialog with null. Clear it in onDismiss or render from a snapshot.

open as a page

In React Native, how would you make a Pressable calculator delete key remove one digit per tap and keep deleting while held, without the repeat getting stuck?

level: seniorimportance: should knowfreq 24%

basics

~20 s

Delete one digit in onPress, start an interval in onLongPress, and clear it in onPressOut plus an unmount cleanup. onPressOut fires on release, slide-off and parent takeover, while onPress is skipped after a long press when onLongPress is set.

open as a page

In React Native, why does a vertical ScrollView nested inside another vertical ScrollView not scroll on Android, and how do you fix it?

level: seniorimportance: should knowfreq 40%

basics

~20 s

On Android, React Native's ScrollView joins nested scrolling only when nestedScrollEnabled is true, so the outer view keeps the drag. Set nestedScrollEnabled on the inner ScrollView and give it a bounded height, or better, redesign to one scroller per axis.

open as a page

In a React Native checkout, uppercasing the postcode inside a controlled TextInput's onChangeText makes typed characters flicker. Why does this happen, and how do you fix it?

level: seniorimportance: should knowfreq 30%

basics

~20 s

The native field shows each keystroke immediately; the uppercased value comes back from JavaScript only after a render, so the raw character appears and is then replaced. Prefer native props such as autoCapitalize="characters" and maxLength, and normalise the value on blur or submit.

open as a page

In a React Native poem reader, how would you show a 'Read more' toggle only when a stanza really exceeds three lines, using onTextLayout?

level: seniorimportance: should knowfreq 34%

basics

~20 s

Measure the stanza's full line count with onTextLayout on a hidden, uncapped copy of the Text at the same width and style. If nativeEvent.lines.length exceeds three, show the toggle and cap the visible Text with numberOfLines={expanded ? 0 : 3}.

open as a page

Since React Native 0.87 deprecated ImageBackground, how do you put a price label over a listing photo, and why can't Image hold children?

level: middleimportance: nice to knowfreq 22%

basics

~20 s

Use a View sized by your layout, render an Image inside it with StyleSheet.absoluteFill, then the price label as a later sibling so it draws on top. Image cannot contain children: it throws. ImageBackground did exactly this wrapping and is deprecated since 0.87.

open as a page

In a React Native ScrollView, how does stickyHeaderIndices pin section headers, and why can it pin the wrong child?

level: middleimportance: nice to knowfreq 25%

basics

~20 s

stickyHeaderIndices lists the positions of a React Native ScrollView's direct children that dock at the top while scrolling. Positions are counted after null and false children are dropped, so a hidden conditional child shifts every later index.

open as a page

showing 31–39 of 39