Learn to handle user interactions like a pro by mastering the 'Play button' logic. We explore onClick, onChange, and how to avoid the common trap of accidental infinite renders.

The correct way is to pass the reference to the function: onClick={handlePlay}. No parentheses. It’s the difference between saying 'Here is the Play button' and actually pressing the Play button yourself while trying to install it.
Explain React event handling: onClick, onChange, handler functions, and common mistake of calling instead of passing a function. Use Play button example. Keep it conceptual.


This usually happens because you are calling the function immediately during the rendering phase instead of passing a reference to it. If your JSX looks like onClick={handlePlay()}, the parentheses tell JavaScript to execute the function right away. If that function updates the state, React triggers a re-render, which executes the function again, creating an infinite loop. To fix this, you should pass the function without parentheses, like onClick={handlePlay}.
To pass data to a handler without executing it during render, you should wrap the function call in an anonymous arrow function. Instead of writing onClick={handlePlay(video.id)}, which causes an immediate execution, you should use onClick={() => handlePlay(video.id)}. The arrow function acts as a "shield" or a container that stays dormant until the actual click event occurs.
Synthetic Events are a cross-browser wrapper around the browser’s native events. React uses this system to act as a universal translator, ensuring that event properties and behaviors are consistent regardless of whether the user is on Chrome, Safari, Firefox, or Edge. This saves developers from having to write specific code to handle the tiny, annoying differences in how various browsers process interactions.
These methods handle different browser behaviors. e.preventDefault() is used to stop the browser's default action, such as preventing a full page reload when a form is submitted. e.stopPropagation() is used to stop an event from "bubbling up" the component tree. For example, if you have a delete button inside a clickable list item, using e.stopPropagation() ensures that clicking the button only triggers the delete logic and doesn't also trigger the parent's click handler.
In a controlled component, React becomes the "single source of truth" for the input's value by syncing it with the component's state via the onChange event. This gives the developer total power over the input, allowing for real-time data validation, automatic formatting (like adding dashes to a phone number), or even preventing certain characters from being typed at all. It ensures the UI and the underlying data are always perfectly in sync.
From Columbia University alumni built in San Francisco
"Instead of endless scrolling, I just hit play on BeFreed. It saves me so much time."
"I never knew where to start with nonfiction—BeFreed’s book lists turned into podcasts gave me a clear path."
"Perfect balance between learning and entertainment. Finished ‘Thinking, Fast and Slow’ on my commute this week."
"Crazy how much I learned while walking the dog. BeFreed = small habits → big gains."
"Reading used to feel like a chore. Now it’s just part of my lifestyle."
"Feels effortless compared to reading. I’ve finished 6 books this month already."
"BeFreed turned my guilty doomscrolling into something that feels productive and inspiring."
"BeFreed turned my commute into learning time. 20-min podcasts are perfect for finishing books I never had time for."
"BeFreed replaced my podcast queue. Imagine Spotify for books — that’s it. 🙌"
"It is great for me to learn something from the book without reading it."
"The themed book list podcasts help me connect ideas across authors—like a guided audio journey."
"Makes me feel smarter every time before going to work"
From Columbia University alumni built in San Francisco
