Notification CenterLoading saved progress…

Notification Center

A notification center shows recent messages and derives its unread badge from the messages that are still unread. Build the familiar bell and panel while keeping the notification array as the single source of truth. React should recompute the badge during render instead of storing a second count that can drift.

Signature

Implement the default App component in App.tsx. It receives no props and owns an array of { id: number; text: string; read: boolean } notifications plus an open boolean.

Examples

  • On first render, the open panel lists four notifications. Three have an unread dot, so the bell badge shows 3.
  • Clicking New comment on your post marks only that row as read. Its dot and highlight disappear, and the badge changes to 2.
  • Clicking the bell closes the panel while keeping the badge visible. Clicking it again restores the same notification state.
  • Clicking the × on Build #42 passed removes that row without also marking it read. Because it was unread, the derived badge decreases by one.
  • Clicking Mark all read clears every dot and hides the badge when the unread count reaches 0.

Starting point

App.tsx contains a static version of the required first frame, and styles.css contains the complete visual design. Replace the repeated mock-up with data-driven JSX and implement the interactions without changing the copy or class names.

Notes

  • Derive the badge. Calculate items.filter((item) => !item.read).length during render; never store the count in state.
  • Update immutably. Use map to mark notifications read and filter to dismiss one so React receives a new array.
  • Stop dismissal bubbling. The × is inside a clickable row, so its handler must call event.stopPropagation().
  • Keep panel state independent. Closing and reopening the panel must not reset or replace the notifications.
  • Preserve accessibility. Keep descriptive labels on the bell and every dismiss button.
WE’RE LISTENING

Help make UIReady better

Found a bug or have an idea? Tell us about it.

Up to 3 files · 5 MiB each · JPG, PNG, WebP, MP4, WebM, MP3, M4A or WAV