What Is React? How to Read an AI-Written Component
React builds interfaces from small reusable components. Here is what that means, and how to read a component an AI wrote without knowing JavaScript well.
React is a JavaScript library for building user interfaces. You describe your screen as a set of small pieces called components, and React keeps what is on the screen in sync with your data. The official docs open with the line that matters most: "React apps are made out of components," and "a component is a piece of the UI that has its own logic and appearance."
If an AI tool built your app, there is a good chance it is written in React. You do not need to write it, but being able to read it tells you what the tool did and lets you ask for changes in the right words.
What a component is
The React docs put it simply: "React components are JavaScript functions that return markup." A component can be as small as a button or as large as a whole page, and components nest inside other components.
function MyButton() {
return (
<button>I'm a button</button>
);
}
export default function MyApp() {
return (
<div>
<h1>Welcome to my app</h1>
<MyButton />
</div>
);
}Two rules show up here. Component names start with a capital letter, so MyButton is a component and button is a plain HTML element. And a component can be reused by writing it like a tag, <MyButton />, as many times as you like.
JSX, the HTML-looking part
The markup inside a component is called JSX. It looks like HTML but sits inside JavaScript. It is optional, though the docs note that "most React projects use JSX for its convenience". It is also stricter than HTML. Tags must be closed, so <br /> instead of <br>, and a component cannot return several tags side by side without a shared parent.
Curly braces let you drop JavaScript values into the markup:
<h1>{user.name}</h1>Props: data that flows down
Props are how a parent hands information to a child. The docs say so directly: "The information you pass down like this is called props." The child reads them from its parameters.
function MyButton({ count, onClick }) {
return (
<button onClick={onClick}>
Clicked {count} times
</button>
);
}Think of props as the inputs on a form that the component cannot change itself.
State: data a component remembers
State is what lets a component remember something between renders, like a counter or the text in a search box. It comes from a hook called useState:
const [count, setCount] = useState(0);That line gives you the current value, count, and a function to change it, setCount. When you call the setter, React runs the component again with the new value and updates the screen. Functions starting with use are called hooks, and the docs give one rule worth remembering: you can only call hooks at the top of your components, not inside loops or conditions.
Read a component the way an AI wrote it
Here is a small component of the kind an AI tool produces all the time. Read it with the pieces above.
function ProductList({ products }) {
const [query, setQuery] = useState("");
const visible = products.filter(p =>
p.title.toLowerCase().includes(query.toLowerCase())
);
return (
<div>
<input value={query} onChange={e => setQuery(e.target.value)} />
<ul>
{visible.map(p => (
<li key={p.id}>{p.title}</li>
))}
</ul>
</div>
);
}Line by line:
ProductList({ products })is a component that receives a list through props.useState("")gives it a piece of memory for the search text, starting empty.visibleis the list filtered by that text. It is calculated fresh every time the component runs.The
inputshows the current text and callssetQuerywhenever someone types, which triggers a new render.visible.map(...)turns each product into a list item. Thekeyis an identifier that must be unique among siblings. The docs say you should pass "a string or a number that uniquely identifies that item among its siblings".
That is the entire loop. State changes, React re-runs the component, the screen updates.
Five things to scan for in generated React code
You do not have to understand every line. These checks catch most problems.
Keys on lists. Every
map()that returns elements should set a stablekey. Using the array position can cause odd behavior when items are reordered.State that should be calculated. If one value can be worked out from another, it usually should not be stored as state.
visibleabove is correct, because it is computed rather than stored.Handlers passed, not called. The docs warn: "Do not call the event handler function: you only need to pass it down."
onClick={handleClick}is right.onClick={handleClick()}runs immediately.Hooks at the top. A hook inside an
ifis a bug, and it often breaks only in some situations.Secrets in the browser. React code runs in the visitor's browser. Anything written in it, including an API key, can be read. If you spot one, move that call to a server.
Where React sits in a project
React handles the screen. It does not store data or send email. Your app still needs a backend, usually reached through an API, and a way to install its dependencies, which is what npm install does. If you want an AI tool to match your look, give your coding agent your design system so it reuses your components. Many projects also use TypeScript, and the guide to converting JavaScript to TypeScript with AI shows what changes. For the full path from idea to working app, start with how to build an app with AI, or read vibe coding for beginners.
FAQ
What is React used for?
Building user interfaces for websites and apps, especially ones with lots of interactive parts like dashboards, forms, and feeds.
Is React a framework or a library?
The React team describes it as a library for building user interfaces. Frameworks built on top of it add routing, data loading, and more.
What is the difference between props and state?
Props are data passed into a component from its parent. State is data a component owns and can change over time.
Do I need to know JavaScript to use React?
To write it by hand, yes. To read and direct AI-generated React, you need the basics above and a habit of checking the five things in the scan list.
What is a hook in React?
A function whose name starts with use, such as useState, that lets a component remember values or connect to other React features.
How did this land?
About the author

Senior Editor, AI & Product
Cecilia leads the Swarmz editorial desk. She has spent a decade turning complex AI and product topics into writing people actually finish, and she owns the blog's quality bar.


