Skip to content

Commit 0ce2709

Browse files
zouyifengMuYunyun
authored andcommitted
add HMR (#59)
尝试用react-hot-loader,使得更新js时候能够热更新,不会刷新页面
1 parent 71d5073 commit 0ce2709

File tree

5 files changed

+69
-5
lines changed

5 files changed

+69
-5
lines changed

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"stage-2"
66
],
77
"plugins": [
8-
["on-demand-loading", {"library": "diana"}]
8+
["on-demand-loading", {"library": "diana"}],
9+
["react-hot-loader/babel"]
910
]
1011
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"react": "^16.6.3",
2828
"react-dom": "^16.6.3",
2929
"react-draft-wysiwyg": "^1.10.0",
30+
"react-hot-loader": "^4.8.2",
3031
"react-loadable": "^5.5.0",
3132
"react-redux": "^5.0.5",
3233
"react-router": "^4.1.1",

src/common/container/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Top from './header'
99
import Contents from './content'
1010
import Footer from './bottom'
1111
import './index.less'
12+
import { hot } from 'react-hot-loader/root'
1213

1314
const { SubMenu } = Menu
1415
const { Sider } = Layout
@@ -18,7 +19,7 @@ const { Sider } = Layout
1819
router: state.router,
1920
})
2021
)
21-
export default class Container extends React.Component {
22+
class Container extends React.Component {
2223
state = {
2324
theme: 'dark',
2425
collapsed: false,
@@ -113,3 +114,5 @@ export default class Container extends React.Component {
113114
)
114115
}
115116
}
117+
118+
export default hot(Container)

src/common/pages/login/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
import createHistory from 'history/createHashHistory'
66

77
import './index.less'
8+
import { hot } from 'react-hot-loader/root'
9+
810

911
const FormItem = Form.Item
1012
const history = createHistory()
@@ -71,4 +73,4 @@ class LoginPage extends React.Component {
7173
}
7274

7375
const Login = Form.create()(LoginPage)
74-
export default Login
76+
export default hot(Login)

yarn.lock

Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3310,6 +3310,11 @@ dom-urls@^1.1.0:
33103310
dependencies:
33113311
urijs "^1.16.1"
33123312

3313+
dom-walk@^0.1.0:
3314+
version "0.1.1"
3315+
resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.1.tgz#672226dc74c8f799ad35307df936aba11acd6018"
3316+
integrity sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=
3317+
33133318
domain-browser@^1.1.1:
33143319
version "1.2.0"
33153320
resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda"
@@ -4055,7 +4060,7 @@ fast-json-stable-stringify@^2.0.0:
40554060
version "2.0.0"
40564061
resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2"
40574062

4058-
fast-levenshtein@~2.0.4:
4063+
fast-levenshtein@^2.0.6, fast-levenshtein@~2.0.4:
40594064
version "2.0.6"
40604065
resolved "https://registry.yarnpkg.com/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz#3d8a5c66883a16a30ca8643e851f19baa7797917"
40614066

@@ -4523,6 +4528,14 @@ global-prefix@^1.0.1:
45234528
is-windows "^1.0.1"
45244529
which "^1.2.14"
45254530

4531+
global@^4.3.0:
4532+
version "4.3.2"
4533+
resolved "https://registry.yarnpkg.com/global/-/global-4.3.2.tgz#e76989268a6c74c38908b1305b10fc0e394e9d0f"
4534+
integrity sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8=
4535+
dependencies:
4536+
min-document "^2.19.0"
4537+
process "~0.5.1"
4538+
45264539
globals@^11.7.0:
45274540
version "11.7.0"
45284541
resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673"
@@ -4811,6 +4824,13 @@ hoist-non-react-statics@^2.3.0, hoist-non-react-statics@^2.3.1, hoist-non-react-
48114824
version "2.5.0"
48124825
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.0.tgz#d2ca2dfc19c5a91c5a6615ce8e564ef0347e2a40"
48134826

4827+
hoist-non-react-statics@^3.3.0:
4828+
version "3.3.0"
4829+
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b"
4830+
integrity sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==
4831+
dependencies:
4832+
react-is "^16.7.0"
4833+
48144834
home-or-tmp@^2.0.0:
48154835
version "2.0.0"
48164836
resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8"
@@ -6260,7 +6280,7 @@ lodash.uniq@^4.5.0:
62606280
version "4.17.5"
62616281
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511"
62626282

6263-
lodash@^4.17.10:
6283+
lodash@^4.17.10, lodash@^4.17.11:
62646284
version "4.17.11"
62656285
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d"
62666286

@@ -6512,6 +6532,13 @@ mimic-response@^1.0.0:
65126532
version "1.0.0"
65136533
resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.0.tgz#df3d3652a73fded6b9b0b24146e6fd052353458e"
65146534

6535+
min-document@^2.19.0:
6536+
version "2.19.0"
6537+
resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685"
6538+
integrity sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=
6539+
dependencies:
6540+
dom-walk "^0.1.0"
6541+
65156542
mini-css-extract-plugin@^0.4.0:
65166543
version "0.4.0"
65176544
resolved "https://registry.yarnpkg.com/mini-css-extract-plugin/-/mini-css-extract-plugin-0.4.0.tgz#ff3bf08bee96e618e177c16ca6131bfecef707f9"
@@ -7717,6 +7744,11 @@ process@^0.11.10:
77177744
version "0.11.10"
77187745
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
77197746

7747+
process@~0.5.1:
7748+
version "0.5.2"
7749+
resolved "https://registry.yarnpkg.com/process/-/process-0.5.2.tgz#1638d8a8e34c2f440a91db95ab9aeb677fc185cf"
7750+
integrity sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8=
7751+
77207752
progress@^2.0.0:
77217753
version "2.0.0"
77227754
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
@@ -8454,6 +8486,26 @@ react-error-overlay@^4.0.1:
84548486
version "4.0.1"
84558487
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-4.0.1.tgz#417addb0814a90f3a7082eacba7cee588d00da89"
84568488

8489+
react-hot-loader@^4.8.2:
8490+
version "4.8.2"
8491+
resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.8.2.tgz#21a00cfca7fc848c53d78c34f6081f5ae3737dda"
8492+
integrity sha512-W5I8ps/32q5zL0mKfGGdPgsZfgljs/tdCTYxM6P1N8GV4+rUAu4g6ysy//5/jJpAFM0Bpgr6HrVLWK9h0jMdrA==
8493+
dependencies:
8494+
fast-levenshtein "^2.0.6"
8495+
global "^4.3.0"
8496+
hoist-non-react-statics "^3.3.0"
8497+
loader-utils "^1.1.0"
8498+
lodash "^4.17.11"
8499+
prop-types "^15.6.1"
8500+
react-lifecycles-compat "^3.0.4"
8501+
shallowequal "^1.0.2"
8502+
source-map "^0.7.3"
8503+
8504+
react-is@^16.7.0:
8505+
version "16.8.6"
8506+
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
8507+
integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==
8508+
84578509
react-json-tree@^0.11.0:
84588510
version "0.11.0"
84598511
resolved "https://registry.yarnpkg.com/react-json-tree/-/react-json-tree-0.11.0.tgz#f5b17e83329a9c76ae38be5c04fda3a7fd684a35"
@@ -9509,6 +9561,11 @@ source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1:
95099561
version "0.6.1"
95109562
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
95119563

9564+
source-map@^0.7.3:
9565+
version "0.7.3"
9566+
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383"
9567+
integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==
9568+
95129569
spdx-correct@^3.0.0:
95139570
version "3.0.0"
95149571
resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82"

0 commit comments

Comments
 (0)