-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
4,210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"presets": ["env", "react"], | ||
"plugins": ["react-hot-loader/babel", "transform-class-properties", "transform-decorators-legacy"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "hot-decorators", | ||
"version": "1.0.0", | ||
"scripts": { | ||
"start": "webpack-dev-server --hot" | ||
}, | ||
"devDependencies": { | ||
"babel-core": "^6.26.0", | ||
"babel-loader": "^7.1.2", | ||
"babel-plugin-transform-class-properties": "^6.24.1", | ||
"babel-plugin-transform-decorators-legacy": "^1.3.4", | ||
"babel-preset-env": "^1.6.1", | ||
"babel-preset-react": "^6.24.1", | ||
"html-webpack-plugin": "^2.30.1", | ||
"webpack": "^3.10.0", | ||
"webpack-dev-server": "^2.9.7" | ||
}, | ||
"dependencies": { | ||
"autobind-decorator": "^2.1.0", | ||
"react": "^16.2.0", | ||
"react-dom": "^16.2.0", | ||
"react-hot-loader": "next" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import { hot } from 'react-hot-loader' | ||
import Counter from './Counter' | ||
|
||
const App = () => ( | ||
<h1> | ||
Hello, world.<br /> | ||
<Counter /> | ||
</h1> | ||
) | ||
|
||
export default hot(module)(App) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react' | ||
import autobind from 'autobind-decorator' | ||
|
||
@autobind | ||
class Counter extends React.Component { | ||
state = { count: 0 } | ||
|
||
componentDidMount() { | ||
this.interval = setInterval(this.increment, 200) | ||
} | ||
|
||
componentWillUnmount() { | ||
clearInterval(this.interval) | ||
} | ||
|
||
increment() { | ||
this.setState(prevState => ({ count: prevState.count + 1 })) | ||
} | ||
|
||
render() { | ||
return this.state.count | ||
} | ||
} | ||
|
||
export default Counter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react' | ||
import { render } from 'react-dom' | ||
import App from './App' | ||
|
||
const root = document.createElement('div') | ||
document.body.appendChild(root) | ||
|
||
render(<App />, root) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* eslint-disable */ | ||
const path = require('path') | ||
const webpack = require('webpack') | ||
const HtmlWebpackPlugin = require('html-webpack-plugin') | ||
|
||
module.exports = { | ||
entry: ['./src/index'], | ||
output: { | ||
path: path.join(__dirname, 'dist'), | ||
filename: 'bundle.js', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
exclude: /node_modules|packages/, | ||
test: /\.js$/, | ||
use: 'babel-loader', | ||
}, | ||
], | ||
}, | ||
plugins: [new HtmlWebpackPlugin(), new webpack.NamedModulesPlugin()], | ||
} |
Oops, something went wrong.