React
A library for component-based interfaces, with state, Server Components and a compiler.
FrontendUsing since 2016 · Featured project: Budzowska Fiutowski i Partnerzy
- Category
- Frontend
- Using since
- 2016
- Featured project
- Budzowska Fiutowski i Partnerzy
In practice
What is React?
React is a library for building interfaces out of components. A component takes data and returns a piece of the view, and when the data changes, React updates what the user sees. That split lets you assemble a large screen from small, reusable parts.
Data flows one way: from a parent component to its children, through props. State is data a component remembers between renders, and changing it refreshes the view. You pull reusable logic out into custom hooks. You describe the view in JSX, a syntax where markup sits next to JavaScript code.
Server Components render ahead of time, outside the browser, so they cannot use state. You add interactivity with Client Components. React Compiler is a build-time tool that optimizes the app on its own, without manual memoization.
- Reach
- Web and native interfaces
- Split
- Server and Client Components
How I work with React
I start with the split into components and with where state lives. The rest follows from those two decisions.
Split into components
I start with the screen drawn as small, reusable parts. Only then do I work out which data flows into them and which of them have to react to the visitor.
Server and client
I keep a component on the server while rendering data is enough. What reacts to the visitor becomes a Client Component, because only there is state needed.
Heavy parts later
Sections that weigh a lot I mount only when the visitor gets close to them. In ENATIV Portfolio the AI chat and the contact form load that way, and animations respect
prefers-reduced-motion.
When it fits, and when it doesn't
React fits where an interface has state and reacts to data.
A good fit when
- A dashboard or app with forms, tables and views that depend on the role.
- An interface that shows a lot of data and has to stay smooth.
- A site with animations and interactive sections, not only text.
- A product that also has a mobile version in React Native, because the component model is the same.
Not a fit when
- A site of plain text and images with no interaction at all.
- A tiny script or widget for which the whole library would be dead weight.
- A team where nobody knows JavaScript or TypeScript.
When you need a framework with routing and server rendering, I describe it in the entry on Next.js.
Frequently asked questions
Building an interface with a lot of state?
Send a list of views, roles and data sources. I will propose the split into components and the line between the server part and the client part.