PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Other / Miscellaneous/Notion

Implement Recursive React JSON Viewer with Collapse

Last updated: Mar 29, 2026

Quick Overview

This question evaluates proficiency in React component design, recursive rendering of nested data structures, per-node expand/collapse state management, safe JSON parsing, and read-only UI rendering within frontend development.

  • medium
  • Notion
  • Other / Miscellaneous
  • Software Engineer

Implement Recursive React JSON Viewer with Collapse

Company: Notion

Role: Software Engineer

Category: Other / Miscellaneous

Difficulty: medium

Interview Round: Technical Screen

Build a React component that accepts a JSON string and renders a pretty-printed, read-only tree view. For each nested object or array, display a toggle (e.g., a 🔽 caret) to collapse/expand that node. Requirements: ( 1) Support arbitrarily deep nesting by recursively rendering child components. ( 2) Parse the input string safely; handle invalid JSON gracefully. ( 3) Maintain per-node expand/collapse state. ( 4) Demonstrate the behavior using input: {name: "bob", age: 5, nicknames: ["bobby", "bobman"], school: {name: "bob university", year: 2015}} where the "school" node can be toggled. ( 5) Briefly explain your component structure, state shape, and complexity considerations.

Quick Answer: This question evaluates proficiency in React component design, recursive rendering of nested data structures, per-node expand/collapse state management, safe JSON parsing, and read-only UI rendering within frontend development.

Notion logo
Notion
Jul 17, 2025, 12:00 AM
Software Engineer
Technical Screen
Other / Miscellaneous
22
0

React JSON Tree Viewer (Read-Only, Recursive)

Design and implement a React component that accepts a JSON string and renders a pretty-printed, read-only tree view. Each nested object or array must be collapsible/expandable via a toggle (e.g., a caret).

Requirements

  1. Support arbitrarily deep nesting by recursively rendering child components.
  2. Parse the input string safely; handle invalid JSON gracefully (show a helpful error without crashing).
  3. Maintain per-node expand/collapse state.
  4. Demonstrate the behavior using the input below. The "school" node should be collapsible/expandable:
    • Provided (non-strict) input: {name: "bob", age: 5, nicknames: ["bobby", "bobman"], school: {name: "bob university", year: 2015}}
    • Valid JSON to use in the demo: {"name":"bob","age":5,"nicknames":["bobby","bobman"],"school":{"name":"bob university","year":2015}}
  5. Briefly explain the component structure, state shape, and complexity considerations.

Assumptions

  • Use modern React (functional components + hooks, React 17/18+).
  • No external libraries required; plain CSS/inline styles are fine.
  • The component is read-only (no editing).

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Other / Miscellaneous•More Notion•More Software Engineer•Notion Software Engineer•Notion 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
  • 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.