useDebugValue

useDebugValue can be used to print out debug information in the console for custom hooks.

useDebugValue can be thought of as a console.log() for React custom hooks.

useDebugEffect cannot be rendered conditionally due to the Hooks rules preventing Hooks being called conditionally.

Using useDebugValue heavily in production code might negatively impact the performance of your app.

Don't leave it in your production code

Example code

export default function useUser() {

const [user, setUser] = useState(getUser());

useDebugValue(user == null ? "No User" : user.name);

return [user, setUser];

}