Below is a small React component that is rendered in the browser under StrictMode in development mode. Your task is to determine what text it will print to console, and explain the reasoning directly in comments on the lines with logs.
19.0.0 and TypeScript 5.8.0 are used.StrictMode.console.log.Switch button once.import React, { StrictMode, useEffect, useState } from 'react';
import { createRoot } from 'react-dom/client';
function RoomLogger() {
const [roomId, setRoomId] = useState('alpha');
useEffect(() => {
console.log('effect:' + roomId);
return () => {
console.log('cleanup:' + roomId);
};
}, [roomId]);
return (
<button onClick={() => setRoomId('beta')}>
Switch
</button>
);
}
createRoot(document.getElementById('root')!).render(
<StrictMode>
<RoomLogger />
</StrictMode>,
);
console.react-dom 19.0.0StrictMode enabledClick a line and write what it prints. Explanation is optional.