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 pageshowhide
explore
- View & Text Rules6 questions
- TextInput Control6 questions
- Images & Backgrounds6 questions
- Pressable & Buttons4 questions
- Modals, Switches & Indicators6 questions
- Keyboard & Safe Areas5 questions
- ScrollView & Refresh6 questions
questions
page 2 of 2In 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?
basics
~20 sPrefetch 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.
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?
basics
~20 sMeasure 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.
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?
basics
~20 sOn 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.
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?
basics
~20 sDelete 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.
In React Native, why does a vertical ScrollView nested inside another vertical ScrollView not scroll on Android, and how do you fix it?
basics
~20 sOn 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.
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?
basics
~20 sThe 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.
In a React Native poem reader, how would you show a 'Read more' toggle only when a stanza really exceeds three lines, using onTextLayout?
basics
~20 sMeasure 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}.
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?
basics
~20 sUse 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.
In a React Native ScrollView, how does stickyHeaderIndices pin section headers, and why can it pin the wrong child?
basics
~20 sstickyHeaderIndices 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.
showing 31–39 of 39