Skip to content

Instantly share code, notes, and snippets.

@foxdonut
Created November 30, 2015 19:16
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save foxdonut/1ff35ce3e0f626a03659 to your computer and use it in GitHub Desktop.
Save foxdonut/1ff35ce3e0f626a03659 to your computer and use it in GitHub Desktop.
Simple React Hello World

Simple React Hello World

Run these commands:

npm i
npm start

You only have to run npm i the first time.

In a separate window, run npm run watch to hot-reload your changes.

{
"name": "hello-react",
"version": "1.0.0",
"description": "Simple React Hello World",
"main": "index.js",
"scripts": {
"start": "browserify -t babelify --outfile public/generated-app.js src/hello.jsx && echo 'Open http://localhost:8000/ in your browser' && (cd public ; python -m SimpleHTTPServer)",
"watch": "watchify -v -t babelify --outfile public/generated-app.js src/hello.jsx"
},
"author": "",
"license": "ISC",
"repository": "none",
"devDependencies": {
"babelify": "^6.3.0",
"browserify": "^11.2.0",
"watchify": "^3.4.0"
},
"dependencies": {
"react": "^0.14.3",
"react-dom": "^0.14.3"
}
}
<!DOCTYPE html>
<html>
<head>
<title>Simple React Hello World</title>
</head>
<body>
<h1>Simple React Hello World</h1>
<div id="app"></div>
<script src="/generated-app.js"></script>
</body>
</html>
import React from "react";
import ReactDOM from "react-dom";
const Hello = function(name) {
return (
<div>Hello, {name}</div>
);
};
const view = Hello("Will");
const element = document.getElementById("app");
ReactDOM.render(view, element);
@will-molloy
Copy link

how does it know my name?

@mohammedrehman33
Copy link

how does it know my name?

IN SON FILE
"name": "hello-react",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment