Skip to content

Commit 34c1970

Browse files
committed
add react-loadable and react-loading
1 parent 555f4f6 commit 34c1970

File tree

7 files changed

+174
-9
lines changed

7 files changed

+174
-9
lines changed

.babelrc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"presets": [
33
"env",
4-
"react",
4+
"react",
55
"stage-0"
66
],
77
"plugins": [
88
"transform-runtime",
99
"transform-decorators-legacy",
1010
"transform-class-properties",
1111
"transform-object-rest-spread",
12-
"react-hot-loader/babel"
12+
"react-hot-loader/babel",
13+
"emotion"
1314
]
14-
}
15+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
"react": "^16.2.0",
3838
"react-dom": "^16.2.0",
3939
"react-hot-loader": "^4.0.0",
40+
"react-loadable": "^5.3.1",
4041
"react-router-dom": "^4.2.2",
42+
"react-spinners": "^0.2.6",
4143
"rimraf": "^2.6.2",
4244
"style-loader": "^0.20.3",
4345
"webpack": "^4.1.1",

src/containers/Loading/Loading.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React, { Component } from 'react';
2+
import { RiseLoader } from 'react-spinners';
3+
import './Loading.less';
4+
5+
const Loading = () => (
6+
<div className='sweet-loading'>
7+
<RiseLoader
8+
color={'#37d7b7'}
9+
loading
10+
size={30}
11+
/>
12+
</div>
13+
);
14+
15+
export default Loading;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.sweet-loading {
2+
height: 100vh;
3+
display: flex;
4+
align-items: center;
5+
justify-content: center;
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"main": "Loading.js"
3+
}

src/containers/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import React from 'react';
22
// import package
33
import { HashRouter as Router, Route, Switch } from 'react-router-dom';
4+
import Loadable from 'react-loadable';
45
// import relative path
5-
import Home from './Home';
6+
import Loading from './Loading';
67
import NotFound from './NotFound';
78

9+
const LoadComponent = loader => Loadable({
10+
loader,
11+
loading: Loading,
12+
})
13+
14+
const Home = LoadComponent(() => import('./Home'));
15+
816
const Main = () => (
917
<Router>
1018
<Switch>

yarn.lock

Lines changed: 135 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@
3232
dependencies:
3333
"@babel/types" "7.0.0-beta.42"
3434

35+
"@babel/helper-module-imports@7.0.0-beta.32":
36+
version "7.0.0-beta.32"
37+
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0-beta.32.tgz#8126fc024107c226879841b973677a4f4e510a03"
38+
dependencies:
39+
"@babel/types" "7.0.0-beta.32"
40+
lodash "^4.2.0"
41+
3542
"@babel/helper-split-export-declaration@7.0.0-beta.42":
3643
version "7.0.0-beta.42"
3744
resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.42.tgz#0d0d5254220a9cc4e7e226240306b939dc210ee7"
@@ -70,6 +77,14 @@
7077
invariant "^2.2.0"
7178
lodash "^4.2.0"
7279

80+
"@babel/types@7.0.0-beta.32":
81+
version "7.0.0-beta.32"
82+
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.32.tgz#c317d0ecc89297b80bbcb2f50608e31f6452a5ff"
83+
dependencies:
84+
esutils "^2.0.2"
85+
lodash "^4.2.0"
86+
to-fast-properties "^2.0.0"
87+
7388
"@babel/types@7.0.0-beta.42", "@babel/types@^7.0.0-beta.40":
7489
version "7.0.0-beta.42"
7590
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.42.tgz#1e2118767684880f6963801b272fd2b3348efacc"
@@ -575,6 +590,12 @@ babel-loader@^7.1.4:
575590
loader-utils "^1.0.2"
576591
mkdirp "^0.5.1"
577592

593+
babel-macros@^1.2.0:
594+
version "1.2.0"
595+
resolved "https://registry.yarnpkg.com/babel-macros/-/babel-macros-1.2.0.tgz#39e47ed6d286d4a98f1948d8bab45dac17e4e2d4"
596+
dependencies:
597+
cosmiconfig "3.1.0"
598+
578599
babel-messages@^6.23.0:
579600
version "6.23.0"
580601
resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e"
@@ -587,6 +608,19 @@ babel-plugin-check-es2015-constants@^6.22.0:
587608
dependencies:
588609
babel-runtime "^6.22.0"
589610

611+
babel-plugin-emotion@^8.0.12, babel-plugin-emotion@^8.0.6:
612+
version "8.0.12"
613+
resolved "https://registry.yarnpkg.com/babel-plugin-emotion/-/babel-plugin-emotion-8.0.12.tgz#2ed844001416b0ae2ff787a06b1804ec5f531c89"
614+
dependencies:
615+
"@babel/helper-module-imports" "7.0.0-beta.32"
616+
babel-macros "^1.2.0"
617+
babel-plugin-syntax-jsx "^6.18.0"
618+
convert-source-map "^1.5.0"
619+
emotion-utils "^8.0.12"
620+
find-root "^1.1.0"
621+
source-map "^0.5.7"
622+
touch "^1.0.0"
623+
590624
babel-plugin-syntax-async-functions@^6.8.0:
591625
version "6.13.0"
592626
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
@@ -631,7 +665,7 @@ babel-plugin-syntax-function-bind@^6.8.0:
631665
version "6.13.0"
632666
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-function-bind/-/babel-plugin-syntax-function-bind-6.13.0.tgz#48c495f177bdf31a981e732f55adc0bdd2601f46"
633667

634-
babel-plugin-syntax-jsx@^6.3.13, babel-plugin-syntax-jsx@^6.8.0:
668+
babel-plugin-syntax-jsx@^6.18.0, babel-plugin-syntax-jsx@^6.3.13, babel-plugin-syntax-jsx@^6.8.0:
635669
version "6.18.0"
636670
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946"
637671

@@ -1488,6 +1522,10 @@ chalk@~0.4.0:
14881522
has-color "~0.1.0"
14891523
strip-ansi "~0.1.0"
14901524

1525+
change-emitter@^0.1.2:
1526+
version "0.1.6"
1527+
resolved "https://registry.yarnpkg.com/change-emitter/-/change-emitter-0.1.6.tgz#e8b2fe3d7f1ab7d69a32199aff91ea6931409515"
1528+
14911529
chardet@^0.4.0:
14921530
version "0.4.2"
14931531
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"
@@ -1823,6 +1861,15 @@ core-util-is@1.0.2, core-util-is@~1.0.0:
18231861
version "1.0.2"
18241862
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
18251863

1864+
cosmiconfig@3.1.0:
1865+
version "3.1.0"
1866+
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-3.1.0.tgz#640a94bf9847f321800403cd273af60665c73397"
1867+
dependencies:
1868+
is-directory "^0.3.1"
1869+
js-yaml "^3.9.0"
1870+
parse-json "^3.0.0"
1871+
require-from-string "^2.0.1"
1872+
18261873
cosmiconfig@^2.1.0, cosmiconfig@^2.1.1:
18271874
version "2.2.2"
18281875
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-2.2.2.tgz#6173cebd56fac042c1f4390edf7af6c07c7cb892"
@@ -2315,6 +2362,19 @@ emojis-list@^2.0.0:
23152362
version "2.1.0"
23162363
resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389"
23172364

2365+
emotion-utils@^8.0.12:
2366+
version "8.0.12"
2367+
resolved "https://registry.yarnpkg.com/emotion-utils/-/emotion-utils-8.0.12.tgz#5e0fd72db3008f26ce4f80b1972df08841df2168"
2368+
2369+
emotion@^8.0.8:
2370+
version "8.0.12"
2371+
resolved "https://registry.yarnpkg.com/emotion/-/emotion-8.0.12.tgz#03de11ce26b1b2401c334b94d438652124c514c6"
2372+
dependencies:
2373+
babel-plugin-emotion "^8.0.12"
2374+
emotion-utils "^8.0.12"
2375+
stylis "^3.3.2"
2376+
stylis-rule-sheet "^0.0.5"
2377+
23182378
encodeurl@~1.0.2:
23192379
version "1.0.2"
23202380
resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59"
@@ -2729,7 +2789,7 @@ faye-websocket@~0.11.0:
27292789
dependencies:
27302790
websocket-driver ">=0.5.1"
27312791

2732-
fbjs@^0.8.16:
2792+
fbjs@^0.8.1, fbjs@^0.8.16:
27332793
version "0.8.16"
27342794
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
27352795
dependencies:
@@ -2811,6 +2871,10 @@ find-cache-dir@^1.0.0:
28112871
make-dir "^1.0.0"
28122872
pkg-dir "^2.0.0"
28132873

2874+
find-root@^1.1.0:
2875+
version "1.1.0"
2876+
resolved "https://registry.yarnpkg.com/find-root/-/find-root-1.1.0.tgz#abcfc8ba76f708c42a97b3d685b7e9450bfb9ce4"
2877+
28142878
find-up@^1.0.0:
28152879
version "1.1.2"
28162880
resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f"
@@ -3292,7 +3356,7 @@ hoek@2.x.x:
32923356
version "2.16.3"
32933357
resolved "https://registry.yarnpkg.com/hoek/-/hoek-2.16.3.tgz#20bb7403d3cea398e91dc4710a8ff1b8274a25ed"
32943358

3295-
hoist-non-react-statics@^2.3.0, hoist-non-react-statics@^2.5.0:
3359+
hoist-non-react-statics@^2.3.0, hoist-non-react-statics@^2.3.1, hoist-non-react-statics@^2.5.0:
32963360
version "2.5.0"
32973361
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.5.0.tgz#d2ca2dfc19c5a91c5a6615ce8e564ef0347e2a40"
32983362

@@ -3877,7 +3941,7 @@ js-tokens@^3.0.0, js-tokens@^3.0.2:
38773941
version "3.0.2"
38783942
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
38793943

3880-
js-yaml@^3.4.3, js-yaml@^3.9.1:
3944+
js-yaml@^3.4.3, js-yaml@^3.9.0, js-yaml@^3.9.1:
38813945
version "3.11.0"
38823946
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.11.0.tgz#597c1a8bd57152f26d622ce4117851a51f5ebaef"
38833947
dependencies:
@@ -4641,6 +4705,12 @@ nopt@^4.0.1:
46414705
abbrev "1"
46424706
osenv "^0.1.4"
46434707

4708+
nopt@~1.0.10:
4709+
version "1.0.10"
4710+
resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee"
4711+
dependencies:
4712+
abbrev "1"
4713+
46444714
normalize-package-data@^2.3.2, normalize-package-data@^2.3.4:
46454715
version "2.4.0"
46464716
resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f"
@@ -4946,6 +5016,12 @@ parse-json@^2.2.0:
49465016
dependencies:
49475017
error-ex "^1.2.0"
49485018

5019+
parse-json@^3.0.0:
5020+
version "3.0.0"
5021+
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-3.0.0.tgz#fa6f47b18e23826ead32f263e744d0e1e847fb13"
5022+
dependencies:
5023+
error-ex "^1.3.1"
5024+
49495025
parse-json@^4.0.0:
49505026
version "4.0.0"
49515027
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0"
@@ -5428,7 +5504,7 @@ promise@^7.1.1:
54285504
dependencies:
54295505
asap "~2.0.3"
54305506

5431-
prop-types@^15.5.4, prop-types@^15.6.0:
5507+
prop-types@^15.5.0, prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.6.0:
54325508
version "15.6.1"
54335509
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca"
54345510
dependencies:
@@ -5578,6 +5654,13 @@ react-dom@^16.2.0:
55785654
object-assign "^4.1.1"
55795655
prop-types "^15.6.0"
55805656

5657+
react-emotion@^8.0.6:
5658+
version "8.0.12"
5659+
resolved "https://registry.yarnpkg.com/react-emotion/-/react-emotion-8.0.12.tgz#3dd94c151197e2e3399e34e3e118df141b5ebb7b"
5660+
dependencies:
5661+
babel-plugin-emotion "^8.0.12"
5662+
emotion-utils "^8.0.12"
5663+
55815664
react-hot-loader@^4.0.0:
55825665
version "4.0.0"
55835666
resolved "https://registry.yarnpkg.com/react-hot-loader/-/react-hot-loader-4.0.0.tgz#3452fa9bc0d0ba9dfc5b0ccfa25101ca8dbd2de2"
@@ -5588,6 +5671,12 @@ react-hot-loader@^4.0.0:
55885671
prop-types "^15.6.0"
55895672
shallowequal "^1.0.2"
55905673

5674+
react-loadable@^5.3.1:
5675+
version "5.3.1"
5676+
resolved "https://registry.yarnpkg.com/react-loadable/-/react-loadable-5.3.1.tgz#9699e9a08fed49bacd69caaa282034b62a76bcdd"
5677+
dependencies:
5678+
prop-types "^15.5.0"
5679+
55915680
react-router-dom@^4.2.2:
55925681
version "4.2.2"
55935682
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-4.2.2.tgz#c8a81df3adc58bba8a76782e946cbd4eae649b8d"
@@ -5611,6 +5700,16 @@ react-router@^4.2.0:
56115700
prop-types "^15.5.4"
56125701
warning "^3.0.0"
56135702

5703+
react-spinners@^0.2.6:
5704+
version "0.2.6"
5705+
resolved "https://registry.yarnpkg.com/react-spinners/-/react-spinners-0.2.6.tgz#15ba678d07636c3cf760563b0efb7b2566f465cb"
5706+
dependencies:
5707+
babel-plugin-emotion "^8.0.6"
5708+
emotion "^8.0.8"
5709+
prop-types "^15.5.10"
5710+
react-emotion "^8.0.6"
5711+
recompose "0.26.0"
5712+
56145713
react@^16.2.0:
56155714
version "16.2.0"
56165715
resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba"
@@ -5727,6 +5826,15 @@ rechoir@^0.6.2:
57275826
dependencies:
57285827
resolve "^1.1.6"
57295828

5829+
recompose@0.26.0:
5830+
version "0.26.0"
5831+
resolved "https://registry.yarnpkg.com/recompose/-/recompose-0.26.0.tgz#9babff039cb72ba5bd17366d55d7232fbdfb2d30"
5832+
dependencies:
5833+
change-emitter "^0.1.2"
5834+
fbjs "^0.8.1"
5835+
hoist-non-react-statics "^2.3.1"
5836+
symbol-observable "^1.0.4"
5837+
57305838
redent@^1.0.0:
57315839
version "1.0.0"
57325840
resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde"
@@ -5882,6 +5990,10 @@ require-from-string@^1.1.0:
58825990
version "1.2.1"
58835991
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-1.2.1.tgz#529c9ccef27380adfec9a2f965b649bbee636418"
58845992

5993+
require-from-string@^2.0.1:
5994+
version "2.0.1"
5995+
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.1.tgz#c545233e9d7da6616e9d59adfb39fc9f588676ff"
5996+
58855997
require-main-filename@^1.0.1:
58865998
version "1.0.1"
58875999
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
@@ -6484,6 +6596,14 @@ style-loader@^0.20.3:
64846596
loader-utils "^1.1.0"
64856597
schema-utils "^0.4.5"
64866598

6599+
stylis-rule-sheet@^0.0.5:
6600+
version "0.0.5"
6601+
resolved "https://registry.yarnpkg.com/stylis-rule-sheet/-/stylis-rule-sheet-0.0.5.tgz#ebae935cc1f6fb31b9b62dba47f2ea8b833dad9f"
6602+
6603+
stylis@^3.3.2:
6604+
version "3.5.0"
6605+
resolved "https://registry.yarnpkg.com/stylis/-/stylis-3.5.0.tgz#016fa239663d77f868fef5b67cf201c4b7c701e1"
6606+
64876607
supports-color@^2.0.0:
64886608
version "2.0.0"
64896609
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
@@ -6520,6 +6640,10 @@ symbol-observable@^0.2.2:
65206640
version "0.2.4"
65216641
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-0.2.4.tgz#95a83db26186d6af7e7a18dbd9760a2f86d08f40"
65226642

6643+
symbol-observable@^1.0.4:
6644+
version "1.2.0"
6645+
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804"
6646+
65236647
table@4.0.2:
65246648
version "4.0.2"
65256649
resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36"
@@ -6640,6 +6764,12 @@ toposort@^1.0.0:
66406764
version "1.0.6"
66416765
resolved "https://registry.yarnpkg.com/toposort/-/toposort-1.0.6.tgz#c31748e55d210effc00fdcdc7d6e68d7d7bb9cec"
66426766

6767+
touch@^1.0.0:
6768+
version "1.0.0"
6769+
resolved "https://registry.yarnpkg.com/touch/-/touch-1.0.0.tgz#449cbe2dbae5a8c8038e30d71fa0ff464947c4de"
6770+
dependencies:
6771+
nopt "~1.0.10"
6772+
66436773
tough-cookie@~2.3.0:
66446774
version "2.3.4"
66456775
resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655"

0 commit comments

Comments
 (0)