Load and Display a React List with useEffect

Read the full interview experience this question came from →

Quick Overview

Load a React list with useEffect while handling endpoint changes, cleanup, stale responses, HTTP and schema errors, stable keys, and user-visible states.

Load and Display a React List with useEffect

Company: xAI

Role: Frontend Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

Implement a React component that uses `useEffect` to load and display a list. ### Constraints & Assumptions The reported task names useEffect and a list but does not provide an endpoint. For this practice version, receive an `endpoint` prop that returns a JSON array of `{id,label}` objects with unique string IDs. Display loading, empty, success, and error states. When the endpoint changes, an old response must not replace the new endpoint's state. ### Clarifying Questions Who owns fetching and caching? What should happen while switching endpoints? Can the request be canceled? How does the component behave on unmount? ### What a Strong Answer Covers A correct effect dependency, cleanup and stale-response protection, HTTP and data-shape error handling, and stable list keys. ### Follow-up Questions Why should the effect callback itself not be async? What can development effect setup/cleanup cycles reveal? How would you add retries or share results among components?

Overview: Load a React list with useEffect while handling endpoint changes, cleanup, stale responses, HTTP and schema errors, stable keys, and user-visible states.

Read the full xAI Frontend Engineer interview experience this question came from

|Home/Software Engineering Fundamentals/xAI
xAI logo
xAI
Sep 15, 2026
mediumFrontend EngineerOnsiteSoftware Engineering Fundamentals
0
0

Implement a React component that uses useEffect to load and display a list.

Constraints & Assumptions

The reported task names useEffect and a list but does not provide an endpoint. For this practice version, receive an endpoint prop that returns a JSON array of {id,label} objects with unique string IDs. Display loading, empty, success, and error states. When the endpoint changes, an old response must not replace the new endpoint's state.

Clarifying Questions Guidance

Who owns fetching and caching? What should happen while switching endpoints? Can the request be canceled? How does the component behave on unmount?

What a Strong Answer Covers Guidance

A correct effect dependency, cleanup and stale-response protection, HTTP and data-shape error handling, and stable list keys.

Follow-up Questions Guidance

Why should the effect callback itself not be async? What can development effect setup/cleanup cycles reveal? How would you add retries or share results among components?

Loading comments...