The easiest way to get started with React is to use this Hello World example code on CodePen. You don’t need to install anything; you can just open it in another tab and follow along as we go through examples. If you’d rather use a local development environment, check out the Installation section.
The smallest React example looks like this:
ReactDOM.render( <h1>Hello, world!</h1>, document.getElementById('root') );
It renders a header saying “Hello, world!” on the page.
The next few sections will gradually introduce you to using React. We will examine the building blocks of React apps: elements and components. Once you master them, you can create complex apps from small reusable pieces.
We also use some of the ES6 syntax in the examples. We try to use it sparingly because it’s still relatively new, but we encourage you to get familiar with arrow functions, classes, template literals,
const statements. You can use the Babel REPL to check what ES6 code compiles to.
© 2013–present Facebook Inc.
Licensed under the Creative Commons Attribution 4.0 International Public License.