I share real-world lessons from building scalable systems at Binance, and running mission-critical cloud ops at GovTech and Singapore Air Force. No fluff, just practical takeaways, hard-earned fixes, and deep dives that matter.
A React component is usually defined in its own file. This makes it easier to reuse via imports. We typically import what we need, and export our components
That said, we can define multiple components in the same file if they’re only used locally
Components are just functions, you can nest them to create parent-child structures. We can compose UI like writing HTML by embedding components inside other components’ JSX
Tip
App.js is usually the UI entry point, which typically holds the layout, routing, context providers etc
Split components into separate files when a file gets too long or cluttered.
Component Lifecycle
The useEffect hook gives us access to lifecycle behaviors (like componentDidMount, componentDidUpdate etc)
You pass a function to useEffect, it runs after render and also on updates
useState returns a pair: the current state value, and a function to update it. You must use the update function (setCount in this case) to change state, or React won’t re-render.
Example
Inputs manage what’s typed into them
Buttons know when they’re clicked or focused
Links know when the mouse is hovering
Props
Important
A component either manages data with State, or receives data via props.
Props allow components to receive data from other components.
Passing data to child component
Pass like HTML attributes from parent component’s JSX: html <WelcomeMessage myprop="somevalue" />.
In the receiving component:
function WelcomeMessage({ myprop }) { return <p>Welcome, {myprop}!</p>; }
You can also pass functions as props so child components can trigger actions in parent components
Data typically flows top-down (parent to child) via props. But if you pass a function down, child components can update parent state: