Frontend School

Dynamic Notification Feed

Machine Coding
medium

Dynamic Notification Feed

Medium
Frontend
React
UI
State Management
Notifications

Overview

The Notification Center is a critical component of any engaging application, keeping users informed about important updates, messages, and activities. For Snap, a dynamic and responsive notification feed is essential for user retention and real-time interaction. This problem focuses on building the core UI and state management for such a feed, allowing users to manage their notifications efficiently.

What you need to do / Task

Your task is to build a React component that displays a list of notifications and allows users to interact with them.

  1. Display Notifications: Render a list of notifications, each showing its message and timestamp. Visually distinguish between read and unread notifications (e.g., different background color, bold text).
  2. Mark as Read (Individual): Implement a button or clickable area on each notification to mark it as read. Once marked, its visual status should update.
  3. Mark All as Read: Provide a global button to mark all currently displayed notifications as read.
  4. Unread Count: Display the total number of unread notifications prominently (e.g., "Unread: 5"). This count should update dynamically as notifications are marked read/unread.
  5. Filter Notifications: Implement a toggle or set of buttons (e.g., "All", "Unread") to filter the displayed notifications.
    • "All": Shows all notifications.
    • "Unread": Shows only unread notifications.

UI/UX expectations

  • The application should have a main container for the Notification Center.
  • A header should display the "Unread" count.
  • Control buttons (e.g., "Mark All as Read", filter buttons) should be clearly visible at the top.
  • Notifications should be displayed in a vertical list.
  • Each notification item should clearly show its content and provide an action to mark it as read.
  • Visual cues (e.g., bolding, background color) should differentiate read from unread notifications.
  • Basic responsiveness is expected, ensuring the layout is usable on a standard desktop browser.

Acceptance criteria

  • Initial render displays all mock notifications, with correct read/unread status.
  • Clicking an individual "Mark as Read" button changes that notification's status and updates its visual representation.
  • Clicking "Mark All as Read" updates the status of all currently displayed notifications to read.
  • The unread count accurately reflects the number of unread notifications at all times.
  • Switching the filter (e.g., from "All" to "Unread") correctly shows only the relevant notifications.
  • Notifications persist their read/unread status when switching filters.

Constraints

Constraints & assumptions

  • You must use React (functional components and hooks).
  • All notification data is provided upfront as an array of objects; no API calls are needed.
  • State management should be handled locally within React components using useState and useEffect as appropriate.
  • Focus on functionality and clean code; extensive styling is not required but the UI should be presentable and usable.
  • The target time for this problem is approximately 45 minutes.

Out of scope

  • Backend integration or API calls for fetching/updating notifications.
  • Persistence of notification state across page reloads (e.g., using localStorage).
  • Real-time updates via WebSockets or other push mechanisms.
  • Complex animations or advanced accessibility features beyond semantic HTML.
  • Routing or multiple pages.

What interviewers evaluate

  • Correctness and Completeness: Does the solution meet all functional requirements? Are edge cases handled?
  • Code Quality and Design: Is the code clean, readable, well-structured, and modular? Are React patterns used effectively?
  • State Management: Is application state managed efficiently and correctly using React hooks?
  • UI/UX Implementation: Is the user interface intuitive and responsive, providing clear feedback for user actions?

Loading editor...