User List with Details Panel
Description
Build a user directory. A nav bar shows a list of users. Selecting a user must remove that user from the list and show their profile details in a side panel next to the list.
The list starts with five users. Selecting a user moves them out of the list (the list shrinks by one) and renders their name, role, email, and location in the details panel. Selecting another user updates the panel to that user and removes them as well. A Reset control restores the full list and clears the details panel.
Optimize re-renders: wrap the user row and the details panel in React.memo, and create the select and reset handlers with useCallback so the memoized children do not re-render when unrelated state changes.
Example 1
The list shows five users and the panel shows a "Select a user" placeholder.
Example 2
Select Ada Lovelace. Ada is removed from the list and the panel shows her role, email, and location.
Constraints
- The initial list contains exactly five users.
- Selecting a user removes exactly that user from the list.
- The details panel shows the selected user's name, role, email, and location.
- Selecting a second user updates the panel and removes the second user.
- Reset restores all five users and clears the panel.
- The list, selected user, and details must be rendered from React state.
- Row and details components use
React.memo; handlers useuseCallback. - List rows, the details panel, and the Reset control must be accessible.
User List with Details Panel
Build a user directory with a selectable list and a details side panel where selecting a user removes them from the list and renders their profile.