πͺWhat are React Hooks?
Hooks are helpers that let a function component:
remember data
react to changes
π§ Core React Hooks (WHAT + WHY)
πΉ useState β data that affects the UI
Why it exists:
React re-runs components often. Without state, values would reset every time.
Use when:
The user should see the change.
πΉ useEffectβ side work after render
Why it exists:
Some work should happen after the UI is painted, not during it.
Used for:
API calls
timers
πΉuseRef β remember without re-render
Why it exists:
Sometimes React needs to remember something without updating the UI.
Two main uses:
DOM access β focus input, scroll, measure
Silent storage β timer IDs, previous values, flags
πΉ useContext β shared/global data
Why it exists:
To avoid passing props through many layers.
Used for:
logged-in user
theme
πΉ useMemo β avoid heavy recalculations
Why it exists:
React re-runs components often β slow calculations can repeat unnecessarily.
Use when:
calculation is expensive
πΉ useCallback β stable functions
Why it exists:
Functions are recreated on every render.
Used mainly when:
passing callbacks to optimized child components
π Rendering Types (WHY they exist)
πΉ CSR β Client Side Rendering
What: Browser builds the UI
Best for: dashboards, internal tools
πΉ SSR β Server Side Rendering
What: Server sends ready HTML
Why: Search engines need content
πΉ SSG β Static Site Generation
What: Page built once at build time
Why: Some content rarely changes
Hope it helps someone else too
Top comments (0)