Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit c98103f

Browse files
committed
react 16 compat
1 parent a0cfef6 commit c98103f

File tree

4 files changed

+31
-25
lines changed

4 files changed

+31
-25
lines changed

demo/game/character.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ export default class Character extends Component {
136136
if (this.isPunching && this.state.spritePlaying === false) {
137137
this.isPunching = false;
138138
}
139-
139+
if (this.isJumping) {
140+
store.setCharacterPosition(body.position);
141+
}
140142
const targetX = store.stageX + (this.lastX - body.position.x);
141143
if (shouldMoveStageLeft || shouldMoveStageRight) {
142144
store.setStageX(targetX);
@@ -177,6 +179,8 @@ export default class Character extends Component {
177179
const { x, y } = characterPosition;
178180
const targetX = x + stageX;
179181

182+
console.log(y);
183+
180184
return {
181185
position: 'absolute',
182186
transform: `translate(${targetX * scale}px, ${y * scale}px)`,

demo/index.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ ReactDOM.render(
1010
document.getElementById('root')
1111
);
1212

13-
module.hot.accept('./presentation', () => {
14-
const NextPresentation = require('./presentation').default;
15-
ReactDOM.render(
16-
<AppContainer>
17-
<NextPresentation />
18-
</AppContainer>,
19-
document.getElementById('root')
20-
);
21-
});
13+
if (process.env.NODE_ENV !== 'production') {
14+
module.hot.accept('./presentation', () => {
15+
const NextPresentation = require('./presentation').default;
16+
ReactDOM.render(
17+
<AppContainer>
18+
<NextPresentation />
19+
</AppContainer>,
20+
document.getElementById('root')
21+
);
22+
});
23+
}

webpack.config.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,31 @@ const path = require('path');
22
const webpack = require('webpack');
33

44
module.exports = {
5-
entry: [
6-
'./demo/index',
7-
],
5+
entry: ['./demo/index'],
86
output: {
97
path: path.join(__dirname, 'dist'),
108
filename: 'bundle.js',
119
publicPath: '/dist/',
1210
},
1311
plugins: [
14-
new webpack.optimize.OccurenceOrderPlugin(),
1512
new webpack.DefinePlugin({
1613
'process.env': {
1714
NODE_ENV: JSON.stringify('production'),
1815
},
1916
}),
17+
new webpack.optimize.UglifyJsPlugin(),
2018
],
2119
module: {
22-
loaders: [{
23-
test: /\.js$/,
24-
exclude: /node_modules/,
25-
loader: 'babel',
26-
}, {
27-
test: /\.css$/,
28-
loader: 'style!css!postcss',
29-
}],
20+
loaders: [
21+
{
22+
test: /\.js$/,
23+
exclude: /node_modules/,
24+
loader: 'babel-loader',
25+
},
26+
{
27+
test: /\.css$/,
28+
loader: 'style-loader!css-loader!postcss-loader',
29+
},
30+
],
3031
},
3132
};

webpack.config.umd.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module.exports = {
66
entry: path.join(__dirname, 'src/index.js'),
77
externals: [
88
{
9-
'react': {
9+
react: {
1010
root: 'React',
1111
commonjs2: 'react',
1212
commonjs: 'react',
@@ -28,11 +28,10 @@ module.exports = {
2828
},
2929
module: {
3030
loaders: [
31-
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
31+
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
3232
],
3333
},
3434
plugins: [
35-
new webpack.optimize.DedupePlugin(),
3635
new webpack.optimize.UglifyJsPlugin({
3736
compress: {
3837
warnings: false,

0 commit comments

Comments
 (0)