React is a JavaScript library for building user interfaces out of components. You describe what the screen should look like for the current data, and when the data changes, React updates the page to match. React, React JS and ReactJS are the same thing: an open source library created at Facebook (now Meta).
Click both buttons. Each Counter keeps its own number, because each one is a separate copy of the component with its own state. Add a third line, <Counter label="Plums" />, and a new independent counter appears.
That short example already shows the three ideas React is built on: components (Counter and App are functions that return UI), JSX (the HTML-like syntax inside return), and state (count, a value that makes React redraw the component when it changes).
The problem React solves
A user interface is a picture of some data. When the data changes, the picture has to change too, and every part of the screen that depends on that data has to change with it. Without a library, you write that code by hand: find each element, then set its text, class or visibility yourself. Each new feature adds another place you have to remember to update.
React flips this around. You write one function that says what the screen should be for a given state, and React works out which parts of the page need to change. This is called declarative UI, as opposed to imperative code that lists every DOM change step by step. Here are both styles side by side in one example:
ByHand gives its paragraph to plain DOM code (the effect only runs that code once React has created the paragraph). It keeps the number in a variable, finds each element with querySelector and sets its text by hand. Declarative only says "show the count, and show whether it is even". Delete the line in handleClick that sets .parity and click a few times: the first row now claims 3 is even, while the second row cannot fall out of sync, because the text is computed from count on every render.
How React updates the page
When state changes, React calls your component function again. That call is a render. The function returns a fresh description of the UI, React compares it with the previous one, and then changes only the parts of the real page that differ. People often call that in-memory description the virtual DOM.
Open the console under the preview and type a few letters. Every keystroke logs one render with the new value. The input keeps its focus and cursor position, because React only touched the text of the paragraph and the input's value, not the whole page. The page on rendering explains exactly when a component renders again.
Components, JSX and state at a glance
Components are JavaScript functions whose names start with a capital letter. They return what should appear on screen, and you use them like HTML tags: <Counter />. A page is a tree of components, from small ones like a button to large ones like a whole settings screen. See components.
JSX is the syntax that lets you write markup inside JavaScript. Curly braces drop back into JavaScript, so {count} shows a value and {items.map(...)} turns an array into a list. A build tool compiles JSX into plain function calls before the browser runs it.
State is data a component remembers between renders. You create it with the useState hook, and calling its setter is how you tell React that something changed. Data flows down from parents to children through props, which are the arguments of a component.
This example uses all of them: a list rendered from an array in state, and a form that adds to it.
Add a task and two things change at once: the list and the count under it. You never told the count to update. Both read from tasks, so both follow it. Change the starting array to [] and the list shows "Nothing to do." instead.
What React is not
React is a library, not a full framework. It covers components, state and turning them into UI, and it deliberately leaves out several things a complete app needs:
- Routing. There is no built-in way to map URLs to pages. React Router and framework routers fill that gap.
- Data fetching and server rendering. React gives you tools such as effects and Suspense, but no opinion on where data comes from or how pages render on a server.
- A build setup. Browsers do not understand JSX, so you need a tool such as Vite to compile it.
Frameworks build on React to supply these parts. Next.js and React Router's framework mode add routing, server rendering and data loading, and the React team recommends starting a full app with one of them. For a client-side app or for learning, Vite with plain React is a small and fast starting point; see how to install React.
React vs React Native
React itself only describes components and how they change. A separate renderer turns them into something you can see. React DOM renders to web pages, which is what every example on this site uses. React Native renders the same kind of components to native iOS and Android views, so you write <View> and <Text> instead of <div> and <p>, and there is no HTML or CSS file. Components, props, state and hooks work the same in both, so what you learn here carries over directly.
When to learn React
Learn React after the JavaScript basics, because everything in React is JavaScript. Before you start, you should be comfortable with:
- variables, functions and arrow functions
- arrays and their
mapandfiltermethods - objects, destructuring and the spread syntax (
...) importandexport- promises and
async/await, for loading data
If those feel familiar, start with JSX and components, then props and state. Effects, refs, context and performance tools come later, once building small interactive components feels natural.
Frequently Asked Questions
What is React used for?
React is used to build interactive user interfaces: web apps, dashboards, forms, single page apps and parts of ordinary websites. With React Native the same component model builds iOS and Android apps.
Is React a framework or a library?
React is a library. It handles components, state and rendering, but it has no built-in router, data fetching layer or build setup. Frameworks such as Next.js and React Router's framework mode add those on top of React.
Is React JS the same as React?
Yes. React, React JS and ReactJS are three names for the same library. The "JS" is there because React is written in and for JavaScript.
Do I need to know JavaScript before learning React?
Yes. React components are JavaScript functions, so you should be comfortable with functions, arrays (map, filter), objects, destructuring, arrow functions, modules and promises first.
What is the difference between React and React Native?
React describes UIs as components. React DOM renders those components into a web page, and React Native renders them as native mobile views. The components, props, state and hooks work the same way in both.