Skip to content

Commit 46c5b4e

Browse files
committed
Add project 17 and 18
1 parent 0a00951 commit 46c5b4e

34 files changed

+11207
-70
lines changed

17/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

17/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"immer": "^2.1.0",
77
"react": "^16.8.3",
88
"react-dom": "^16.8.3",
9-
"react-redux": "^5.0.7",
9+
"react-redux": "^7.1.0-rc.1",
1010
"react-scripts": "2.1.5",
1111
"redux": "^4.0.1",
1212
"redux-actions": "^2.6.4",

17/src/containers/CounterContainer.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
import React, { useCallback } from 'react';
2-
import { connect } from 'react-redux';
2+
import { useSelector, useDispatch } from 'react-redux';
33
import Counter from '../components/Counter';
44
import { increase, decrease } from '../modules/counter';
55

6-
const CounterContainer = ({ number, increase, decrease }) => {
6+
const CounterContainer = () => {
7+
const number = useSelector(state => state.counter.number);
8+
const dispatch = useDispatch();
9+
const onIncrease = useCallback(() => dispatch(increase()), [dispatch]);
10+
const onDecrease = useCallback(() => dispatch(decrease()), [dispatch]);
11+
712
return (
8-
<Counter number={number} onIncrease={increase} onDecrease={decrease} />
13+
<Counter number={number} onIncrease={onIncrease} onDecrease={onDecrease} />
914
);
1015
};
1116

12-
export default connect(
13-
state => ({
14-
number: state.counter.number,
15-
}),
16-
{
17-
increase,
18-
decrease,
19-
},
20-
)(CounterContainer);
17+
export default CounterContainer;

17/src/containers/TodosContainer.js

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,29 @@
11
import React from 'react';
2-
import { connect } from 'react-redux';
2+
import { useSelector } from 'react-redux';
33
import { changeInput, insert, toggle, remove } from '../modules/todos';
44
import Todos from '../components/Todos';
5+
import useActions from '../lib/useActions';
56

6-
const TodosContainer = ({
7-
input,
8-
todos,
9-
changeInput,
10-
insert,
11-
toggle,
12-
remove,
13-
}) => {
7+
const TodosContainer = () => {
8+
const { input, todos } = useSelector(({ todos }) => ({
9+
input: todos.input,
10+
todos: todos.todos
11+
}));
12+
13+
const [onChangeInput, onInsert, onToggle, onRemove] = useActions(
14+
[changeInput, insert, toggle, remove],
15+
[]
16+
);
1417
return (
1518
<Todos
1619
input={input}
1720
todos={todos}
18-
onChangeInput={changeInput}
19-
onInsert={insert}
20-
onToggle={toggle}
21-
onRemove={remove}
21+
onChangeInput={onChangeInput}
22+
onInsert={onInsert}
23+
onToggle={onToggle}
24+
onRemove={onRemove}
2225
/>
2326
);
2427
};
2528

26-
export default connect(
27-
// 비구조화 할당을 통하여 todos 를 분리하여
28-
// state.todos.input 대신 todos.input 을 사용
29-
({ todos }) => ({
30-
input: todos.input,
31-
todos: todos.todos,
32-
}),
33-
{
34-
changeInput,
35-
insert,
36-
toggle,
37-
remove,
38-
},
39-
)(TodosContainer);
29+
export default React.memo(TodosContainer);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import { connect } from 'react-redux';
3+
import Counter from '../components/Counter';
4+
import { increase, decrease } from '../modules/counter';
5+
6+
const CounterContainer = ({ number, increase, decrease }) => {
7+
return (
8+
<Counter number={number} onIncrease={increase} onDecrease={decrease} />
9+
);
10+
};
11+
12+
export default connect(
13+
state => ({
14+
number: state.counter.number
15+
}),
16+
{
17+
increase,
18+
decrease
19+
}
20+
)(CounterContainer);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react';
2+
import { connect } from 'react-redux';
3+
import { changeInput, insert, toggle, remove } from '../modules/todos';
4+
import Todos from '../components/Todos';
5+
6+
const TodosContainer = ({
7+
input,
8+
todos,
9+
changeInput,
10+
insert,
11+
toggle,
12+
remove,
13+
}) => {
14+
return (
15+
<Todos
16+
input={input}
17+
todos={todos}
18+
onChangeInput={changeInput}
19+
onInsert={insert}
20+
onToggle={toggle}
21+
onRemove={remove}
22+
/>
23+
);
24+
};
25+
26+
export default connect(
27+
// 비구조화 할당을 통하여 todos 를 분리하여
28+
// state.todos.input 대신 todos.input 을 사용
29+
({ todos }) => ({
30+
input: todos.input,
31+
todos: todos.todos,
32+
}),
33+
{
34+
changeInput,
35+
insert,
36+
toggle,
37+
remove,
38+
},
39+
)(TodosContainer);

17/src/lib/useActions.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { bindActionCreators } from 'redux';
2+
import { useDispatch } from 'react-redux';
3+
import { useMemo } from 'react';
4+
5+
export default function useActions(actions, deps) {
6+
const dispatch = useDispatch();
7+
return useMemo(
8+
() => {
9+
if (Array.isArray(actions)) {
10+
return actions.map(a => bindActionCreators(a, dispatch));
11+
}
12+
return bindActionCreators(actions, dispatch);
13+
},
14+
deps ? [dispatch, ...deps] : deps
15+
);
16+
}

17/yarn.lock

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -722,12 +722,12 @@
722722
dependencies:
723723
regenerator-runtime "^0.12.0"
724724

725-
"@babel/runtime@^7.1.2":
726-
version "7.3.4"
727-
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.%3Cspan%20class="x x-first x-last">3.4.tgz#73d12ba819e365fcf7fd152aed56d6df97d21c83"
728-
integrity sha512-IvfvnMdSaLBateu0jfsYIpZTxAc2cKEXEMiezGGN75QcBcecDUKd3PgLAncT0oOgxKy8dd8hrJKj9MfzgfZd6g==
725+
"@babel/runtime@^7.4.5":
726+
version "7.4.5"
727+
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.%3Cspan%20class="x x-first x-last">4.5.tgz#582bb531f5f9dc67d2fcb682979894f75e253f12"
728+
integrity sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==
729729
dependencies:
730-
regenerator-runtime "^0.12.0"
730+
regenerator-runtime "^0.13.2"
731731

732732
"@babel/template@^7.1.0", "@babel/template@^7.1.2", "@babel/template@^7.2.2":
733733
version "7.2.2"
@@ -4328,7 +4328,7 @@ [email protected]:
43284328
resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.1.tgz#9634502aa12c445dd5a7c5734b572bb8738aacbb"
43294329
integrity sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==
43304330

4331-
hoist-non-react-statics@^3.1.0:
4331+
hoist-non-react-statics@^3.3.0:
43324332
version "3.3.0"
43334333
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz#b09178f0122184fb95acf525daaecb4d8f45958b"
43344334
integrity sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==
@@ -7652,15 +7652,6 @@ prompts@^0.1.9:
76527652
kleur "^2.0.1"
76537653
sisteransi "^0.1.1"
76547654

7655-
prop-types@^15.6.1:
7656-
version "15.7.2"
7657-
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
7658-
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
7659-
dependencies:
7660-
loose-envify "^1.4.0"
7661-
object-assign "^4.1.1"
7662-
react-is "^16.8.1"
7663-
76647655
prop-types@^15.6.2:
76657656
version "15.7.1"
76667657
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.1.tgz#2fa61e0a699d428b40320127733ee2931f05d9d1"
@@ -7669,6 +7660,15 @@ prop-types@^15.6.2:
76697660
object-assign "^4.1.1"
76707661
react-is "^16.8.1"
76717662

7663+
prop-types@^15.7.2:
7664+
version "15.7.2"
7665+
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.7.2.tgz#52c41e75b8c87e72b9d9360e0206b99dcbffa6c5"
7666+
integrity sha512-8QQikdH7//R2vurIJSutZ1smHYTcLpRWEOlHnzcWHmBYrOGUysKwSsrC89BCiFj3CbrfJ/nXFdJepOVrY1GCHQ==
7667+
dependencies:
7668+
loose-envify "^1.4.0"
7669+
object-assign "^4.1.1"
7670+
react-is "^16.8.1"
7671+
76727672
property-information@^5.0.0, property-information@^5.0.1:
76737673
version "5.0.1"
76747674
resolved "https://registry.yarnpkg.com/property-information/-/property-information-5.0.1.tgz#c3b09f4f5750b1634c0b24205adbf78f18bdf94f"
@@ -7888,7 +7888,7 @@ react-error-overlay@^5.1.3:
78887888
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-5.1.3.tgz#16fcbde75ed4dc6161dc6dc959b48e92c6ffa9ad"
78897889
integrity sha512-GoqeM3Xadie7XUApXOjkY3Qhs8RkwB/Za4WMedBGrOKH1eTuKGyoAECff7jiVonJchOx6KZ9i8ILO5XIoHB+Tg==
78907890

7891-
react-is@^16.6.0, react-is@^16.7.0:
7891+
react-is@^16.7.0:
78927892
version "16.8.3"
78937893
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.3.tgz#4ad8b029c2a718fc0cfc746c8d4e1b7221e5387d"
78947894
integrity sha512-Y4rC1ZJmsxxkkPuMLwvKvlL1Zfpbcu+Bf4ZigkHup3v9EfdYhAlWAaVyA19olXq2o2mGn0w+dFKvk3pVVlYcIA==
@@ -7898,23 +7898,22 @@ react-is@^16.8.1:
78987898
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.1.tgz#a80141e246eb894824fb4f2901c0c50ef31d4cdb"
78997899
integrity sha512-ioMCzVDWvCvKD8eeT+iukyWrBGrA3DiFYkXfBsVYIRdaREZuBjENG+KjrikavCLasozqRWTwFUagU/O4vPpRMA==
79007900

7901-
react-lifecycles-compat@^3.0.0:
7902-
version "3.0.4"
7903-
resolved "https://registry.yarnpkg.com/react-%3Cspan%20class="x x-first x-last">lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"
7904-
integrity sha512-fBASbA6LnOU9dOU2eW7aQ8xmYBSXUIWr+UmF9b1efZBazGNO+rcXT/icdKnYm2pTwcRylVUYwW7H1PHfLekVzA==
7901+
react-is@^16.8.6:
7902+
version "16.8.6"
7903+
resolved "https://registry.yarnpkg.com/react-%3Cspan%20class="x x-first x-last">is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16"
7904+
integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA==
79057905

7906-
react-redux@^5.0.7:
7907-
version "5.1.1"
7908-
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-%3Cspan%20class="x x-first x-last">5.1.1.tgz#88e368682c7fa80e34e055cd7ac56f5936b0f52f"
7909-
integrity sha512-LE7Ned+cv5qe7tMV5BPYkGQ5Lpg8gzgItK07c67yHvJ8t0iaD9kPFPAli/mYkiyJYrs2pJgExR2ZgsGqlrOApg==
7906+
react-redux@^7.1.0-rc.1:
7907+
version "7.1.0-rc.1"
7908+
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-%3Cspan%20class="x x-first x-last">7.1.0-rc.1.tgz#af42e20901e443191ace09392b1c8b85721a5de6"
7909+
integrity sha512-ULeRoensr1LZqs1f7HiWYWN67ppRuoBbB5NfSKn3Py92G7qNSnNb+GC2quMgOXXrMBmcq0C9hvPn3xwhQmUXKw==
79107910
dependencies:
7911-
"@babel/runtime" "^7.1.2"
7912-
hoist-non-react-statics "^3.1.0"
7911+
"@babel/runtime" "^7.4.5"
7912+
hoist-non-react-statics "^3.3.0"
79137913
invariant "^2.2.4"
7914-
loose-envify "^1.1.0"
7915-
prop-types "^15.6.1"
7916-
react-is "^16.6.0"
7917-
react-lifecycles-compat "^3.0.0"
7914+
loose-envify "^1.4.0"
7915+
prop-types "^15.7.2"
7916+
react-is "^16.8.6"
79187917

79197918
79207919
version "2.1.5"
@@ -8121,6 +8120,11 @@ regenerator-runtime@^0.12.0:
81218120
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de"
81228121
integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==
81238122

8123+
regenerator-runtime@^0.13.2:
8124+
version "0.13.2"
8125+
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz#32e59c9a6fb9b1a4aff09b4930ca2d4477343447"
8126+
integrity sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==
8127+
81248128
regenerator-transform@^0.13.3:
81258129
version "0.13.3"
81268130
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.13.3.tgz#264bd9ff38a8ce24b06e0636496b2c856b57bcbb"

18/learn-middleware/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

18/learn-middleware/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
2+
3+
## Available Scripts
4+
5+
In the project directory, you can run:
6+
7+
### `npm start`
8+
9+
Runs the app in the development mode.<br>
10+
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
11+
12+
The page will reload if you make edits.<br>
13+
You will also see any lint errors in the console.
14+
15+
### `npm test`
16+
17+
Launches the test runner in the interactive watch mode.<br>
18+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
19+
20+
### `npm run build`
21+
22+
Builds the app for production to the `build` folder.<br>
23+
It correctly bundles React in production mode and optimizes the build for the best performance.
24+
25+
The build is minified and the filenames include the hashes.<br>
26+
Your app is ready to be deployed!
27+
28+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
29+
30+
### `npm run eject`
31+
32+
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
33+
34+
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
35+
36+
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
37+
38+
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
39+
40+
## Learn More
41+
42+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
43+
44+
To learn React, check out the [React documentation](https://reactjs.org/).
45+
46+
### Code Splitting
47+
48+
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
49+
50+
### Analyzing the Bundle Size
51+
52+
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
53+
54+
### Making a Progressive Web App
55+
56+
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
57+
58+
### Advanced Configuration
59+
60+
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
61+
62+
### Deployment
63+
64+
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
65+
66+
### `npm run build` fails to minify
67+
68+
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

18/learn-middleware/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "learn-middleware",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"axios": "^0.19.0",
7+
"react": "^16.8.4",
8+
"react-dom": "^16.8.4",
9+
"react-redux": "^6.0.1",
10+
"react-scripts": "2.1.8",
11+
"redux": "^4.0.1",
12+
"redux-actions": "^2.6.5",
13+
"redux-devtools-extension": "^2.13.8",
14+
"redux-logger": "^3.0.6",
15+
"redux-saga": "^1.0.2",
16+
"redux-thunk": "^2.3.0"
17+
},
18+
"scripts": {
19+
"start": "react-scripts start",
20+
"build": "react-scripts build",
21+
"test": "react-scripts test",
22+
"eject": "react-scripts eject"
23+
},
24+
"eslintConfig": {
25+
"extends": "react-app"
26+
},
27+
"browserslist": [
28+
">0.2%",
29+
"not dead",
30+
"not ie <= 11",
31+
"not op_mini all"
32+
]
33+
}
3.78 KB
Binary file not shown.

0 commit comments

Comments
 (0)