-
Notifications
You must be signed in to change notification settings - Fork 0
Hello World
murajun1978 edited this page Jun 7, 2016
·
6 revisions
ReactでHello Worldヘ(^o^)ノ
- ディレクトリを作成するだけ
$ mkdir es6-react-sample
$ cd es6-react-sample
$ npm init -y
- npm(Node.jsのPackageManager)
$ npm i -S react react-dom
$ npm i -D webpack webpack-dev-server babel-loader babel-core babel-preset-es2015 babel-preset-react
module.exports = {
entry: './main.js',
output: {
path: './',
filename: 'index.js'
},
devServer: {
inline: true,
port: 5000
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}
]
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hands-on with React.js and ES6</title>
</head>
<body>
<div id="app"></div>
<script src="index.js"></script>
</body>
</html>
import React from 'react'
class App extends React.Component {
render(){
return <div>Hello World</div>
}
}
export default App
import React from 'react'
import ReactDom from 'react-dom'
import App from './App'
ReactDom.render(<App />, document.getElementById('app'))
{
"name": "es6-react-hands-on",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.1.0",
"react-dom": "^15.1.0"
},
"devDependencies": {
"babel-core": "^6.9.1",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
}
}
$ tree
.
|-- App.js
|-- README.md
|-- index.html
|-- main.js
|-- package.json
`-- webpack.config.js