0
0
React Nativemobile~20 mins

Swipeable list items in React Native - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Swipe Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ui_behavior
intermediate
1:30remaining
Swipeable list item behavior
What happens when you swipe a list item to the left using a typical swipeable list component in React Native?
AThe item reveals hidden action buttons like Delete or Archive behind it.
BThe item immediately deletes itself without confirmation.
CThe entire list scrolls horizontally instead of vertically.
DNothing happens; swipe gestures are ignored by default.
Attempts:
2 left
💡 Hint
Think about common email apps where you swipe left on a message.
lifecycle
intermediate
1:30remaining
State update after swipe action
After a user swipes a list item and taps the Delete button, what is the best way to update the list in React Native?
ADirectly modify the list array without updating state; React Native will detect changes automatically.
BReload the entire app to refresh the list.
CRemove the item from the state array and call setState or useState setter to update the list.
DUse a timeout to delay the removal of the item from the list.
Attempts:
2 left
💡 Hint
React Native UI updates when state changes.
📝 Syntax
advanced
2:00remaining
Correct usage of Swipeable component
Which code snippet correctly implements a swipeable list item using the 'react-native-gesture-handler' Swipeable component?
React Native
import React from 'react';
import { View, Text, Button } from 'react-native';
import { Swipeable } from 'react-native-gesture-handler';

function ListItem({ item, onDelete }) {
  const renderRightActions = () => (
    <Button title="Delete" onPress={() => onDelete(item.id)} />
  );

  return (
    <Swipeable renderRightActions={renderRightActions}>
      <View><Text>{item.text}</Text></View>
    </Swipeable>
  );
}
ASwipeable component wraps the item view and uses renderRightActions prop to show buttons on swipe.
BSwipeable component must be inside the item view, not wrapping it.
CSwipeable component requires a renderLeftActions prop only; renderRightActions is invalid.
DSwipeable component does not support buttons; use TouchableOpacity instead.
Attempts:
2 left
💡 Hint
Check the official docs for Swipeable usage.
🔧 Debug
advanced
2:00remaining
Swipeable item not responding to gestures
You implemented Swipeable list items, but swiping does nothing. What is the most likely cause?
AYou need to import Swipeable from 'react-native' instead of 'react-native-gesture-handler'.
BYou used TouchableOpacity inside Swipeable, which disables gestures.
CYou did not set a fixed height on the list items.
DYou forgot to wrap your app with GestureHandlerRootView from 'react-native-gesture-handler'.
Attempts:
2 left
💡 Hint
Gesture handler library requires a special root wrapper.
🧠 Conceptual
expert
2:30remaining
Managing multiple swipeable items open
In a list with many swipeable items, what is the best approach to ensure only one item is open (swiped) at a time?
AUse a global state to track all open items and close them after a timeout.
BKeep a ref to the currently open Swipeable and close it programmatically before opening another.
CDisable swipe gestures on all items except the first one.
DAllow multiple items to stay open; users can close them manually.
Attempts:
2 left
💡 Hint
Think about how to control one open item at a time.