Understanding React Hooks
Understanding React Hooks
React hooks revolutionized how we write components. Let's look at the two most common ones.
useState
Used for managing state in functional components.
const [count, setCount] = useState(0);
useEffect
Used for side effects like data fetching or DOM manipulation.
useEffect(() => { console.log("Component mounted"); }, []);
They make code much cleaner than class components!