PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers
|Home/Other / Miscellaneous/Scale AI

Implement Hook and Modify UI Interactions

Last updated: May 9, 2026

Quick Overview

This question evaluates a candidate's ability to implement reusable React hooks, manage asynchronous data fetching with loading/error/refetch semantics, transform API responses, and wire component state for modal, collapsible list, and button-driven UI interactions.

  • medium
  • Scale AI
  • Other / Miscellaneous
  • Software Engineer

Implement Hook and Modify UI Interactions

Company: Scale AI

Role: Software Engineer

Category: Other / Miscellaneous

Difficulty: medium

Interview Round: Technical Screen

You are given starter code with basic API and UI scaffolding in a coding environment. Complete the following tasks: 1) Implement a custom React hook for function components that calls the provided API and converts the returned data into a different specified format. Use useEffect with an async function and return transformed data along with loading and error states. 2) Modify the existing UI to: open and close a modal; expand and collapse a list; and add several buttons that perform simple, specified actions. Ensure all interactions are properly wired to component state and the hook.

Quick Answer: This question evaluates a candidate's ability to implement reusable React hooks, manage asynchronous data fetching with loading/error/refetch semantics, transform API responses, and wire component state for modal, collapsible list, and button-driven UI interactions.

Scale AI logo
Scale AI
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Other / Miscellaneous
5
0

Task: Implement a custom React hook and wire UI interactions

Context

You are working in a React app that already includes a basic API module and a simple UI scaffold (a page with a list and a modal placeholder). Your goal is to:

  • Create a reusable custom hook that fetches data via the provided API, transforms it, and exposes loading/error states.
  • Update the UI so that a modal can open/close, a list can expand/collapse, and multiple buttons perform simple, specified actions.

Assume the starter code includes an API function (for example, api.getItems) that returns a promise resolving to an array of raw items. If your scaffold names the function differently, use that instead. You may design the data transformation either by passing a transform function to the hook or by hard-coding a simple transform inside the component for demonstration.

Requirements

  1. Custom hook
    • Implement a hook (e.g., useApiData ) for function components that:
      • Calls the provided API function on mount (and when dependencies change) using useEffect with an inner async function.
      • Transforms the returned data into a different format (via a transform function argument or an internal mapping).
      • Returns { data, loading, error } and also a refetch function.
      • Handles errors and toggles loading correctly.
      • Guards against setting state on unmounted components (e.g., via an isMounted flag or AbortController ).
  2. UI interactions
    • Add state and handlers to:
      • Open and close a modal.
      • Expand and collapse a list.
      • Provide several buttons that perform simple actions.
    • Wire everything to component state and the hook.
  3. Buttons to implement (minimum)
    • Refresh Data: triggers a refetch using the hook.
    • Clear Error: clears any current error state exposed by the hook.
    • Increment Counter: increments a local counter displayed in the UI.
    • Toggle List: expands/collapses the list content.
  4. Display behavior
    • Show loading and error states near the list.
    • When the list is collapsed, show a summary (e.g., 'N items hidden'). When expanded, render the items.
    • Modal should be visible only when open, and provide an in-modal Close action.
  5. Constraints
    • Use React function components and Hooks only.
    • Use useEffect with an inner async function (the effect callback itself should not be async).
    • Keep the hook reusable and decoupled from specific endpoints as much as possible.

What to deliver

  • The custom hook implementation.
  • The updated component(s) showing the modal, collapsible list, and buttons with wired behavior.
  • Minimal notes or comments explaining how to run/refetch and how the transform works.

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Other / Miscellaneous•More Scale AI•More Software Engineer•Scale AI Software Engineer•Scale AI Other / Miscellaneous•Software Engineer Other / Miscellaneous
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • Careers
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.