Dashboard

React

Choose a question track. Theory builds the concepts; debugging applies them to code and real problems.

Code-focused scenarios that ask you to diagnose behavior and choose a practical fix.

Reactยท Debugging & Problem SolvingMid-level
Question 1 of 4
Scenario
You are working on a React component that fetches user information when the selected user ID changes.
Code
tsx
function UserProfile({ userId }: { userId: string }) {
  const [user, setUser] = useState(null);

  useEffect(() => {
    fetchUser(userId).then(setUser);
  }, []);

  return <div>{user?.name}</div>;
}

What is the main issue with this implementation?

Help us improve CodingReady

Allow anonymous analytics to help us understand practice usage. You can reject analytics and continue using the site.