Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Native Interview Exercise

A small Expo / React Native app used as a live coding exercise for React Native developer interviews.

The app is meant to fetch a list of users from the Random User API and display them in a scrollable list, showing a spinner while loading and an error message if the request fails.

The exercise

The candidate should complete the following parts in order:

1. Add the missing code to make the app functional

The app compiles, but it does not work as intended. Find what is missing and fix it so that the list of users loads and renders correctly.

2. Handle API errors

Make sure API errors are surfaced to the user via the ErrorMessage component.

To verify the error handling works, temporarily break the API URL:

https://randomuser.me/aaaaaa/?page=1&results=10&seed=abc

The error should show up in the UI. Then switch it back to continue the exercise:

https://randomuser.me/api/?page=1&results=10&seed=abc

3. Replace the ScrollView with a FlatList

Refactor the list rendering to use a FlatList instead of a ScrollView.

Discussion point: the candidate should be able to explain the difference between the two (eager rendering of all children vs. lazy/virtualized rendering, memory usage, when to use each).

4. Add pagination

Load more users as the user scrolls to the end of the list, using the page query parameter of the API.

Running the app

npm install
npx expo start

Then open the app in the Expo Go app on your phone, or in an iOS/Android emulator.

Project structure

  • App.tsx — main app component (the exercise happens here)
  • components/Spinner.tsx — loading indicator
  • components/ErrorMessage.tsx — error display

License

Licensed under the Apache License 2.0.

About

React Native live coding exercise for developer interviews

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages