()
| 6 | import PhotoGrid from './components/PhotoGrid' |
| 7 | |
| 8 | export default function App() { |
| 9 | const [state, dispatch] = useReducer(reducer, initialState) |
| 10 | |
| 11 | const { photos, nextPage, loading, error } = state |
| 12 | |
| 13 | // We'll show an error only if the first page fails to load |
| 14 | if (photos.length === 0) { |
| 15 | if (loading) { |
| 16 | return ( |
| 17 | <View style={styles.container}> |
| 18 | <ActivityIndicator animating={true} /> |
| 19 | </View> |
| 20 | ) |
| 21 | } |
| 22 | |
| 23 | if (error) { |
| 24 | return ( |
| 25 | <View style={styles.container}> |
| 26 | <Text>Failed to load photos!</Text> |
| 27 | </View> |
| 28 | ) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | return <PhotoGrid numColumns={3} photos={photos} /> |
| 33 | } |
| 34 | |
| 35 | const styles = StyleSheet.create({ |
| 36 | container: { |
nothing calls this directly
no outgoing calls
no test coverage detected