Home›Knowledge Bank›React Core Concepts: Components, Hooks and State Explained
Software Development

React Core Concepts: Components, Hooks and State Explained

A developer guide to the building blocks of modern React applications

Share
Quick answer

React is a JavaScript library for building user interfaces out of reusable components, where state changes trigger re-renders that React efficiently reconciles through its virtual DOM. Hooks like useState and useEffect let functional components manage data and side effects without writing class-based code. Understanding how components, props, state, and hooks interact is the foundation for almost every React interview question you'll face.

React shows up in job postings, codebases, and architecture discussions across nearly every enterprise IT shop, but the terminology around it gets muddled fast. Teams conflate "component" with "class," confuse state with props, and treat hooks as magic rather than a coherent system. This article walks through what React actually is, how its rendering model works under the hood, how hooks replaced older patterns, and what the architecture means practically for teams building and maintaining production applications.

What Is React, Really?

React is a UI library, not a framework. That distinction matters: React only handles rendering views in response to data changes. It doesn't dictate routing, data fetching, or project structure the way a full framework would — you assemble those pieces yourself or adopt a meta-framework built on top of it.

The core idea is component-based architecture. Instead of building one monolithic page, you break the UI into small, self-contained pieces — a button, a card, a navigation bar — each responsible for its own markup, logic, and styling. Those pieces compose into larger screens.

JSX is the syntax extension that lets you write HTML-like markup directly inside JavaScript. It looks like templating, but it isn't — it's syntactic sugar that compiles down to plain JavaScript function calls describing what the UI should look like.

This is where the real mindset shift happens. Vanilla DOM manipulation is imperative: you write step-by-step instructions telling the browser exactly how to find an element and mutate it. React is declarative: you describe what the UI should look like for a given state, and React figures out how to get the DOM there. That shift is often the hardest part for developers coming from jQuery-style scripting, and it's conceptually similar to the broader shift developers experience when they move between frontend vs backend roles and have to reason about state and rendering differently than they do about request/response cycles.

Components, Props, and JSX Explained

Modern React is built almost entirely around functional components — plain JavaScript functions that return JSX. Class components still exist in older codebases, but new development overwhelmingly favors functions paired with hooks.

Props (short for properties) are how data flows into a component. They're passed down from a parent component as arguments, and the component reads them to decide what to render. This flow is intentionally one-directional — data moves top-down, never sideways or upward without explicit callbacks.

Under the hood, JSX isn't HTML at all. Every JSX tag compiles to a call to React.createElement, which returns a plain JavaScript object describing the element, its props, and its children. The browser never sees JSX directly — a build step transforms it first.

A few composition rules keep components predictable and reusable:

  • Single responsibility: a component should do one thing well — rendering a list item, not the entire page.
  • Props are read-only: a component must never mutate the props it receives; it only reads them.
  • Composition over inheritance: React favors nesting components inside one another over building class hierarchies.
  • Pure rendering: given the same props and state, a component should produce the same output every time.

Get trained in Software Development

Start your React.js journey — get a free 1:1 consultation.

Related courses

What do these skills pay? Check the IT Salary Calculator → salaries by role, country and experience.

State and the Render Cycle

State is data that a component owns and can change over time — form input values, toggle flags, fetched API results. Unlike props, state is local to the component (unless deliberately shared) and triggers a re-render whenever it's updated.

Calling useState's setter function doesn't mutate a variable in place. It tells React "this component's data has changed, please re-evaluate it." React then re-runs the component function, producing a new description of the UI.

That new description gets compared against the previous one using the virtual DOM — a lightweight in-memory representation of the UI tree. React runs a diffing/reconciliation algorithm to find exactly what changed, then applies only those minimal updates to the real DOM.

This matters because direct DOM manipulation is expensive. By batching comparisons in memory first, React avoids unnecessary layout recalculations and repaints, which is a major reason React-based UIs stay responsive even as they grow complex.

Batching takes this a step further. When multiple state updates happen within the same event handler, React groups them into a single re-render pass rather than re-rendering after each individual change. This avoids redundant work and keeps the UI consistent mid-update.

Think of React less as a tool that updates your page and more as a tool that redraws it from scratch every time — the "magic" is simply that it's extremely good at figuring out which parts of that redraw you never actually see.

Hooks Explained: useState, useEffect, and Beyond

Hooks are functions that let functional components tap into features — state, lifecycle behavior, context — that were previously only available in class components. They were introduced to solve a real problem: class components scattered related logic across multiple lifecycle methods, making it hard to follow and reuse.

The most common hooks you'll use daily:

  • useState: declares a piece of local state and returns a value plus a setter function to update it.
  • useEffect: runs side effects — data fetching, subscriptions, manual DOM work — after render, and can clean up after itself when the component unmounts or dependencies change.
  • useContext: reads a value from React's context system without needing to pass it down through every intermediate component as props.
  • useRef: holds a mutable value that persists across renders without triggering a re-render when it changes — commonly used for DOM references.
  • useMemo and useCallback: memoize expensive calculations or function references so they aren't recreated on every render, which helps performance in larger component trees.

Hooks come with two firm rules: only call them at the top level of a component (never inside loops, conditions, or nested functions), and only call them from React function components or other custom hooks. Breaking these rules confuses React's internal bookkeeping about which hook belongs to which state slot.

Hooks replaced class lifecycle methods like componentDidMount and componentDidUpdate because they let you group related logic together by concern rather than by lifecycle phase, and they make that logic reusable across components without the ceremony of inheritance or higher-order components.

Why React's Architecture Matters for Teams

For engineering leaders, React's appeal isn't aesthetic — it's operational. Component reuse means a design system built once gets consumed across dozens of screens, cutting duplicate work and visual inconsistency.

Predictable state management — especially once a team adopts consistent patterns for where state lives — makes bugs easier to trace, because data flows in one direction instead of being mutated from arbitrary places.

React's ecosystem maturity is also a practical asset. Routing libraries, state management tools, testing utilities, and meta-frameworks built on React have had years to stabilize, which reduces the risk of betting a product on unproven tooling.

There's a hiring dimension too: React's large adoption means a correspondingly large talent pool, which shortens hiring cycles and lowers onboarding friction compared to niche or in-house frameworks.

At scale, all of this feeds into maintainability. Teams that enforce clear component boundaries and consistent state patterns find it dramatically easier to onboard new engineers into a years-old codebase than teams working with tangled, ad hoc DOM manipulation.

Practical Patterns for Structuring Real Components

Composition is the default way to build complex UI from simple pieces — nesting a Card component inside a List, which sits inside a Page. Favor passing components as children or props over building deeply configurable single components with dozens of flags.

Lifting state up solves the common problem of two sibling components needing to share data. Instead of duplicating state in both, move it to their nearest common parent and pass it down as props along with update handlers.

When state needs to reach many components at different depths, Context avoids the tedium of passing props through every intermediate layer — useful for theming, authentication state, or locale settings, though it's not a full replacement for dedicated state management in very large apps.

Custom hooks let you extract reusable stateful logic — a useFetch hook, a useForm hook — out of components entirely, so multiple components can share behavior without duplicating code or resorting to inheritance.

On file organization, most teams converge on one of two approaches:

  • Grouping by type: separate folders for components, hooks, and utilities — simple for smaller codebases.
  • Grouping by feature: each feature folder contains its own components, hooks, and tests — scales better as the application grows.

Common Misconceptions and Interview Pitfalls

A handful of misunderstandings come up repeatedly, both in day-to-day development and in technical interviews:

  • "React is a framework": it's a library focused on rendering; routing, state architecture, and build tooling are separate decisions layered on top.
  • Confusing state and props: props are passed in from a parent and read-only; state is owned and managed internally by the component itself.
  • Misunderstanding re-renders: a re-render doesn't mean the entire DOM is rebuilt — reconciliation ensures only genuinely changed nodes are touched.
  • Over-relying on useEffect: many developers reach for useEffect to synchronize derived values that could simply be calculated directly during render, adding unnecessary complexity and bugs.
  • Assuming hooks run only once: hooks run on every render unless their dependencies explicitly prevent it, which trips up developers expecting class-like lifecycle guarantees.

Testing and Shipping React Applications

Component-level testing typically combines a test runner with a library that renders components in a simulated DOM and lets you assert on rendered output and user interactions, rather than testing internal implementation details.

For full user-flow verification, teams layer in automated browser testing to confirm that real browser behavior — navigation, form submission, visual rendering — matches expectations across environments.

Build tooling compiles JSX and modern JavaScript down into browser-compatible bundles, handling code splitting and asset optimization so production bundles stay lean.

Shipping reliably depends on continuous integration pipelines that run tests and builds automatically on every change, catching regressions before they reach users.

Deployment itself increasingly relies on containerized deployment, giving teams consistent, reproducible environments from a developer's machine through to production servers. Teams building AI-assisted features into React front ends often pair this foundation with structured upskilling, such as a Generative AI training programme, to bridge UI engineering with model-backed functionality.

Key takeaways
  • React is a UI library built around reusable, composable components, not a complete application framework.
  • State changes drive re-renders, and the virtual DOM diffing process is what makes those updates efficient rather than costly.
  • Hooks like useState and useEffect let functional components manage state and side effects, replacing most class component patterns.
  • Props flow one direction (parent to child); state is local to a component, and mixing up the two is a frequent interview and debugging error.
  • Rules of hooks (only call at the top level, only in React functions) and dependency arrays are the most common sources of subtle bugs.

Glossary

  • Component: A reusable, self-contained function that returns UI markup, the basic building block of a React application
  • JSX: A syntax extension that lets you write HTML-like markup inside JavaScript, compiled into React.createElement calls
  • Hook: A function (like useState or useEffect) that lets functional components use state, lifecycle behavior, or other React features
  • State: Data that a component owns and manages internally, which triggers a re-render whenever it changes
  • Props: Read-only data passed from a parent component to a child component to configure its behavior or content
  • Virtual DOM: An in-memory representation of the UI that React uses to calculate the minimal set of real DOM updates needed after a state change

Frequently asked questions

Is React a framework or a library?

React is a library, not a full framework. It focuses specifically on building UI components and managing rendering; routing, state management at scale, and data fetching are handled by separate libraries like React Router or Redux, which is why React setups vary more between companies than framework-based alternatives.

What is the difference between state and props?

Props are data passed into a component from its parent and are read-only inside that component. State is data a component manages internally and can change over time, triggering a re-render. A common interview question is explaining that props flow down while state is local and mutable through setter functions.

What is the Virtual DOM and why does it matter?

The virtual DOM is a lightweight in-memory representation of the actual DOM. When state changes, React builds a new virtual DOM tree, diffs it against the previous one, and only applies the minimal set of real DOM updates needed. This reconciliation process is why React apps can update frequently without expensive full-page re-renders.

When should you use useEffect versus useState?

useState stores and updates a value that affects what's rendered, like form input or a toggle. useEffect handles side effects that happen after render, like fetching data, subscribing to events, or syncing with external systems. A frequent mistake is using useEffect to derive values that could simply be computed during render.

What is prop drilling and how do you avoid it?

Prop drilling happens when you pass props through several layers of components that don't use the data themselves, just to reach a deeply nested child. You avoid it with the Context API for shared state, or by restructuring components to colocate state closer to where it's used, or with a state management library for complex apps.

What are the most common React interview questions?

Expect questions on the difference between state and props, how hooks replaced lifecycle methods, what the virtual DOM does, why keys matter in lists, how useEffect's dependency array works, and how to lift state up between sibling components. Interviewers often follow up by asking you to debug a snippet with a stale closure or missing dependency.


← Back to Knowledge Bank

Ready to build this capability?

Browse our upcoming batches — live, instructor-led, delivered on Orbit.