Online React.js Compiler
Write, run and test React.js code online, right in your browser. This free online React.js editor needs no installation or signup — just type your code and click Run.
React is a JavaScript library for building user interfaces from reusable components. Practise JSX, props, state and hooks and see the result update in the preview.
How to use the React.js editor
- Write your code in the editor on the left.
- Click Run to update the preview.
- See your page render in the output panel and adjust your code until it looks right.
Sample React.js code
function App() {
const [count, setCount] = React.useState(0);
return <button onClick={() => setCount(count + 1)}>Clicked {count} times</button>;
}
More React.js examples to try
Controlled input with state
The input value lives in React state, and the greeting updates as you type.
function App() {
const [name, setName] = React.useState("");
return (
<div>
<input value={name} onChange={e => setName(e.target.value)} placeholder="Your name" />
<p>Hello, {name || "stranger"}!</p>
</div>
);
}
Rendering a list
Renders an array with map(). Each item needs a unique key.
function App() {
const fruits = ["Apple", "Mango", "Banana"];
return (
<ul>
{fruits.map(f => <li key={f}>{f}</li>)}
</ul>
);
}
Common React.js errors and how to fix them
Warning: Each child in a list should have a unique "key" prop- Add a stable
keyto elements created inmap(), e.g.<li key={item.id}>. Adjacent JSX elements must be wrapped in an enclosing tag- A component must return one root element. Wrap siblings in a
<div>or a fragment<>...</>. Too many re-renders- State is being set during render, e.g.
onClick={setCount(1)}. Pass a function instead:onClick={() => setCount(1)}. Invalid hook call- Hooks such as
useStatemay only be called at the top level of a function component, not inside loops or conditions.
Frequently asked questions
Is this online React.js compiler free?
Yes. It is completely free to use, with no signup required to write and run code.
Do I need to install anything?
No. It all works from your web browser, so there is nothing to download or set up — it works on Windows, macOS, Linux, Chromebooks and phones.
Can I see my page as I build it?
Yes. Click Run and the output panel renders your code, so you can see changes straight away.
Is this good for learning React.js?
Yes. It is ideal for practising exercises, testing small programs and trying out ideas from tutorials, because you can run code instantly without configuring an environment.
Other online compilers
Python Compiler Java Compiler C Compiler C++ Compiler C# Compiler JavaScript Compiler TypeScript Compiler SQL Compiler HTML Compiler Go Compiler Rust Compiler R Compiler PHP Compiler Kotlin Compiler Swift Compiler Scala Compiler Dart Compiler Ruby Compiler Prolog Compiler Perl Compiler
Editor powered by OneCompiler.