Step 1: Update the Counter
Component
Modify the existing Counter.jsx
component to use the useEffect
hook.
Use useEffect
to log a message to the console every time the counter is incremented.
Show Solution
Step 2: Test and Observe
useEffect
dependency array and observe how it affects the behavior (e.g., try removing count
from the array).Step 3: Extension
useEffect
without a dependency array to log a message when the Counter
component mounts. Observe the differences between this and the previous useEffect
.