React "Hello World" Examples

April 24, 2016 ยท View on GitHub

Below are a small collection of React examples to get anyone started using React. They progress from simpler to more complex/full featured.

They will hopefully get you over the initial learning curve of the hard parts of React (JSX, props vs. state, lifecycle events, etc).

Usage

You will want to create an index.html file and copy/paste the contents of 1-base.html and then create a scripts.js file and copy/paste the contents of one of the examples into it.

Serving the examples

You will need to serve these examples using HTTP. You cannot just open the HTML files in a web browser. The easiest way to do this on Linux/OSX is the Python web server:

python -m SimpleHTTPServer 8000

As I don't use windows, I can't really help but check out this article on StackOverflow.

Going Further

Contribute

See things that should be added, improved or clarified? Let me know in the comments!

Updates

April 24, 2016:

  • Updating to use ReactDOM
  • Fixing various typos (thanks commenters for pointing them out!)
  • Update to use newest React
  • Use Babel instead of JSXTranformer