Logo home 9

Over 10 years we helping companies reach their financial and branding goals. Onum is a values-driven SEO agency dedicated.

CONTACTS
Category
Embedded IoT Solutions
Read Time
7 min read
Published
October 25, 2024
Status
Published

React is small at its core. Most difficulty comes from learning the ecosystem before understanding the five ideas the library is actually built on.

React is small at its core. Most of the difficulty people experience comes from learning the ecosystem around it — routers, state libraries, build tools — before understanding the handful of ideas the library itself is built on.

There are really five: components, props, state, the render cycle, and effects. Everything else is a consequence of those. This guide covers each one, the mental model that makes them click, and the mistakes that follow from misunderstanding them.

Concept 1

Components: UI as Functions

A React component is a function that takes data and returns a description of what should appear. It does not touch the DOM; it describes the result and lets React work out what to change.

That inversion is the central idea. In traditional DOM programming you say “find this element and change its text”. In React you say “given this data, the interface looks like this” — and React compares the new description with the previous one and applies the minimal set of changes.

The practical consequence is that an entire class of bug disappears: the interface can no longer drift out of sync with the data, because it is derived from it on every render.

Concept 2

Props: Data Flows Down

Props are the arguments passed into a component. They are read-only — a component may use them but never modify them.

Data flows in one direction: from parent to child. When a child needs to cause a change, the parent passes down a function for the child to call. The parent still owns the data; the child only signals intent.

This one-way flow is what makes React applications traceable. When a value is wrong you can follow it upward to the component that owns it, rather than searching for whatever code mutated it last.

Concept 3

State: Data That Changes Over Time

State is data a component owns and can change. Updating it tells React the component needs to be rendered again.

State updates are asynchronous
Calling a setter does not change the value immediately; it schedules a re-render. Reading the variable on the next line gives the old value, which surprises almost everyone once.
Never mutate state directly
Pushing into an array or assigning to an object property does not trigger a re-render, because the reference has not changed. Create a new array or object instead.
Keep state as low as possible
Put it in the lowest component that needs it, and lift it up only when siblings must share it. Pushing everything to the top causes unnecessary re-renders across the tree.
Do not duplicate derived values
If something can be computed from existing state, compute it during render rather than storing it. Duplicated state is how interfaces end up internally inconsistent.
Concept 4

The Render Cycle and Reconciliation

When state or props change, React re-runs the component function to produce a new description of the interface, compares it against the previous one, and updates only the parts of the real DOM that actually differ.

Two implications matter in practice:

  • Render functions must be pure. Given the same props and state they should produce the same output and cause no side effects. React may call them more than you expect.
  • Keys identify list items. When rendering a list, a stable key tells React which item is which between renders. Using an array index as the key causes wrong behaviour when items are inserted, removed, or reordered — a classic source of inputs showing the wrong values.
Concept 5

Effects: Talking to the Outside World

Rendering is pure, but applications must do impure things: fetch data, set timers, subscribe to events. Effects are where that belongs — code that runs after render, deliberately separated from it.

Three rules prevent most effect-related bugs:

  • Declare dependencies honestly. Every value the effect reads belongs in its dependency list. Omitting one produces stale data that is painful to diagnose.
  • Clean up what you start. Timers, subscriptions, and in-flight requests must be cancelled when the component unmounts or dependencies change, or you get memory leaks and updates to components that no longer exist.
  • Do not use effects to transform data. If a value can be derived from props and state, compute it during render. Using an effect to copy state into other state is the most common unnecessary-effect pattern.

If you are reaching for an effect, first check whether the value can simply be calculated during render.

Practice

Habits That Keep React Codebases Sane

1Keep components small and single-purpose
A component doing one thing is easy to name, test and reuse. Difficulty naming one usually means it is doing too much.
2Separate data fetching from presentation
Components that only receive props and render are trivial to test and reuse. Keep the fetching in dedicated hooks or container components.
3Use stable keys from your data
Database IDs, not array indices. This single habit prevents a whole family of confusing list bugs.
4Add state management only when needed
Local state and context handle most applications. Reach for a global store when prop drilling genuinely hurts, not by default.
5Adopt TypeScript early
Typed props catch an entire category of integration mistakes at compile time, and they document components better than comments do.
6Measure before optimising
Memoisation has a cost and is frequently applied where it changes nothing. Profile first; most re-render concerns turn out not to matter.

For where React sits within a wider application stack, see why the MERN stack became so popular.

FAQ

Frequently Asked Questions

What are the core concepts of React?
Five: components that describe UI as a function of data, props that pass data down and are read-only, state that a component owns and can change, the render and reconciliation cycle that updates only what differs, and effects for interacting with the outside world.
What is the difference between props and state?
Props are passed in from a parent and are read-only; state is owned by the component and can be changed, triggering a re-render. If a child needs to cause a change, the parent passes down a function rather than letting the child modify props.
Why does my state not update immediately?
Because state setters schedule a re-render rather than assigning immediately. Reading the variable on the next line returns the previous value. Use the updated value in the next render, or pass a function to the setter when the new value depends on the old one.
Why should you not use array index as a React key?
Because keys tell React which list item is which between renders. Indices shift when items are inserted, removed or reordered, so React matches up the wrong elements — commonly showing input values attached to the wrong row. Use stable IDs from your data.
When should you use a useEffect?
For genuinely external work: fetching data, timers, subscriptions, or manual DOM interaction. If a value can be derived from existing props and state, compute it during render instead — using an effect to copy state into other state is the most common misuse.
Do you need Redux or another state library?
Usually not at first. Local state plus context covers most applications. Introduce a global store when prop drilling becomes genuinely painful or when many distant components share complex state, rather than adopting one by default.
Wrapping Up

Conclusion

React rests on five ideas: components describe the interface as a function of data, props flow down, state triggers re-renders, reconciliation applies the minimum change, and effects handle everything outside that pure model.

Almost every React bug traces back to one of them being misunderstood — mutated state, missing dependencies, index keys, or effects doing work that belonged in render. Learn the five properly and the ecosystem around them becomes much easier to evaluate.

About MetaDesk Global

Engineering the Next Generation of Connected Products

MetaDesk Global helps startups and enterprises develop intelligent connected products that combine embedded systems, Industrial IoT, Edge AI, and cloud technologies. Our expertise includes:

Industrial IoT (IIoT) Solutions Embedded Firmware Development Edge AI Development Predictive Maintenance Systems PCB Design IoT Gateway Development Cloud Integration OTA Firmware Updates AIoT Product Development End-to-End Product Engineering

From hardware design to AI-powered industrial platforms, we build scalable solutions for the next generation of connected products.

Start Your Project

Building a Connected Product?

We design IIoT sensor networks, Edge AI pipelines, and secure cloud platforms — from prototype to production.

Request a Free Quote →