React is a JavaScript library for building user interfaces out of components, which are functions that take inputs called props and return a description of what should appear on screen. When data changes, React re-renders the affected components and updates only the parts of the real DOM that differ. This guide explains what React is and how components, props, state and rendering fit together, using React 19 and function components.
React was created at Facebook and released as open source in 2013. It is maintained by Meta and a large community and is one of the most widely used tools for web interfaces.
React is a library focused on the view layer. You describe the UI for a given state, and React keeps the browser in sync. It does not include a router or a data-fetching solution of its own; you add those with other packages or through a framework such as Next.js or React Router.
Three ideas define React:
Use a build tool or a framework generator rather than loading React by hand. A common lightweight start is Vite.
The dev server prints a local address. The entry file mounts the root component into the page.
A component is a JavaScript function whose name starts with a capital letter and which returns JSX, a syntax that looks like HTML but is compiled to JavaScript.
Components can contain other components, so a page becomes a tree. A few JSX rules to remember:
<>...</>.className instead of class, and htmlFor instead of for.<img /> and <input />.Props are the inputs of a component. They are read-only: a component must never change its own props.
The children prop holds whatever you place between a component's opening and closing tags, which is how you build wrappers such as layouts and cards.
State is memory that belongs to a component. The useState hook returns the current value and a function to update it.
Calling setLikes does not change the variable immediately. It schedules a re-render, and on the next render likes has the new value. Never mutate state directly; always create a new value. For arrays and objects that means copying:
Render lists with map and give each item a stable key so React can match items between renders.
Events use camelCase handler props such as onClick, onChange and onSubmit, and you pass a function, not a string.
Understanding the cycle prevents most beginner bugs.
useEffect run after the commit, for work such as fetching data or subscribing to events.Because components re-run often, keep side effects out of the function body and inside event handlers or effects.
React describes itself as a library for the user interface. Routing, data loading and server rendering come from companion tools or from frameworks built on React.
Yes. Arrow functions, destructuring, array methods such as map and filter, modules and promises appear in nearly every React component.
JSX is a syntax extension that lets you write markup inside JavaScript. A compiler turns it into regular function calls before it runs in the browser.
No for new code. Function components with hooks are the current standard, and class components are only seen in older codebases.
React builds interfaces from components: functions that take props and return JSX. State, managed with hooks such as useState, triggers re-renders, and React updates only the DOM parts that changed. Keep components pure, treat props and state as immutable, give list items stable keys, and put side effects in handlers or effects.