Skip to content

Commit c9f2566

Browse files
authored
Updated Guide and refactored playground project to work with the most recent TypeScript 3.7 and React & Redux type definitions. (#193)
* Updated deps * Updated deps and refactored code to fix breaking changes * Fixed issue with HOC Fixed #111 * Added an example of nested HOC with connect. Fixed #5 * Updated readme Intro & TOC * Updated PR template * Added new section with Nested HOC - wrapping a component, injecting props and connecting to redux #5 * Updated dev deps
1 parent 4d340bf commit c9f2566

20 files changed

+7476
-2936
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99

1010
## Checklist
1111

12-
* [ ] I have edited `README_SOURCE.md` (NOT `README.md`)
13-
* [ ] I have run `sh ./generate-readme.sh` script to generate an updated `README.md` (alternatively you can run `node ./generate-readme.js`)
14-
1512
* [ ] I have read [CONTRIBUTING.md](https://github.com/piotrwitek/react-redux-typescript-guide/blob/master/CONTRIBUTING.md)
13+
* [ ] I have edited `README_SOURCE.md` (NOT `README.md`)
14+
* [ ] I have run CI script locally `npm run ci-check` to generate an updated `README.md`
1615
* [ ] I have linked all related issues above
1716
* [ ] I have rebased my branch
1817

README.md

Lines changed: 228 additions & 124 deletions
Large diffs are not rendered by default.

README_SOURCE.md

Lines changed: 119 additions & 68 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 1042 additions & 86 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"devDependencies": {
3-
"@types/node": "8.5.1",
4-
"all-contributors-cli": "5.4.0",
3+
"all-contributors-cli": "6.9.3",
54
"doctoc": "1.4.0",
6-
"husky": "1.3.1"
5+
"husky": "3.0.9"
76
},
87
"scripts": {
9-
"ci-check": "npm run readme:generate",
10-
"doctoc": "doctoc --maxlevel=4 README_SOURCE.md",
8+
"ci-check": "npm run doctoc && npm run readme:generate",
9+
"doctoc": "doctoc --maxlevel=3 README_SOURCE.md",
1110
"readme:generate": "node generate-readme",
1211
"contributors:check": "all-contributors check",
1312
"contributors:add": "all-contributors add",

playground/package-lock.json

Lines changed: 5919 additions & 2535 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

playground/package.json

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -21,34 +21,35 @@
2121
"build-storybook": "build-storybook -s public"
2222
},
2323
"dependencies": {
24-
"@types/jest": "24.0.11",
25-
"@types/node": "11.13.8",
26-
"@types/prop-types": "15.7.1",
27-
"@types/react": "16.8.14",
28-
"@types/react-dom": "16.8.4",
29-
"@types/react-redux": "7.0.8",
30-
"@types/react-router-dom": "4.3.2",
24+
"@testing-library/react": "9.3.1",
25+
"@types/jest": "24.0.21",
26+
"@types/node": "12.12.5",
27+
"@types/prop-types": "15.7.3",
28+
"@types/react": "16.9.11",
29+
"@types/react-dom": "16.9.3",
30+
"@types/react-redux": "7.1.5",
31+
"@types/react-router-dom": "5.1.2",
3132
"axios": "^0.19.0",
32-
"connected-react-router": "6.5.0",
33+
"connected-react-router": "6.5.2",
3334
"cuid": "2.1.6",
3435
"prop-types": "15.7.2",
35-
"react": "16.8.6",
36-
"react-dom": "16.8.6",
37-
"react-redux": "7.1.0",
38-
"react-redux-typescript-scripts": "1.5.0",
39-
"react-router-dom": "4.3.1",
40-
"react-scripts": "3.0.1",
41-
"react-testing-library": "7.0.0",
42-
"redux": "4.0.1",
43-
"redux-observable": "1.1.0",
36+
"react": "16.11.0",
37+
"react-dom": "16.11.0",
38+
"react-redux": "7.1.1",
39+
"react-redux-typescript-scripts": "1.6.2",
40+
"react-router-dom": "5.1.2",
41+
"react-scripts": "3.2.0",
42+
"redux": "4.0.4",
43+
"redux-observable": "1.2.0",
4444
"redux-thunk": "2.3.0",
4545
"reselect": "4.0.0",
46-
"rxjs": "6.5.1",
47-
"tslib": "1.9.3",
48-
"tslint": "5.16.0",
49-
"typesafe-actions": "4.2.0",
50-
"typescript": "3.4.5",
51-
"utility-types": "3.5.0"
46+
"rxjs": "6.5.3",
47+
"tslib": "1.10.0",
48+
"tslint": "5.20.0",
49+
"tslint-react": "4.1.0",
50+
"typesafe-actions": "5.1.0",
51+
"typescript": "3.7.1-rc",
52+
"utility-types": "3.9.0"
5253
},
5354
"browserslist": [
5455
">0.2%",
@@ -57,14 +58,14 @@
5758
"not op_mini all"
5859
],
5960
"devDependencies": {
60-
"@storybook/addon-actions": "5.1.9",
61-
"@storybook/addon-links": "5.1.9",
62-
"@storybook/addon-storyshots": "5.1.9",
63-
"@storybook/addons": "5.1.9",
64-
"@storybook/react": "5.1.9",
65-
"@types/storybook__addon-storyshots": "4.0.1",
61+
"@storybook/addon-actions": "5.2.5",
62+
"@storybook/addon-links": "5.2.5",
63+
"@storybook/addon-storyshots": "5.2.5",
64+
"@storybook/addons": "5.2.5",
65+
"@storybook/react": "5.2.5",
66+
"@types/storybook__addon-storyshots": "5.1.1",
6667
"@types/storybook__react": "4.0.2",
67-
"react-test-renderer": "16.8.6",
68-
"require-context.macro": "1.0.4"
68+
"react-test-renderer": "16.11.0",
69+
"require-context.macro": "1.2.2"
6970
}
7071
}

playground/src/components/class-counter-with-default-props.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ export class ClassCounterWithDefaultProps extends React.Component<
2121
count: this.props.initialCount,
2222
};
2323

24-
componentWillReceiveProps({ initialCount }: Props) {
25-
if (initialCount != null && initialCount !== this.props.initialCount) {
26-
this.setState({ count: initialCount });
27-
}
28-
}
29-
3024
handleIncrement = () => {
3125
this.setState({ count: this.state.count + 1 });
3226
};

playground/src/connected/fc-counter-connected-own-props.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { createStore, combineReducers } from 'redux';
33
import { Provider } from 'react-redux';
4-
import { render, fireEvent, cleanup } from 'react-testing-library';
4+
import { render, fireEvent, cleanup } from '@testing-library/react';
55

66
import { FCCounterConnectedOwnProps as ConnectedCounter } from './fc-counter-connected-own-props';
77

playground/src/features/counters/actions.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@ import { action } from 'typesafe-actions';
22

33
import { ADD, INCREMENT } from './constants';
44

5-
// CLASSIC API
5+
/* SIMPLE API */
6+
67
export const increment = () => action(INCREMENT);
78
export const add = (amount: number) => action(ADD, amount);
89

9-
// ALTERNATIVE API - allow to use reference to "action-creator" function instead of "type constant"
10-
// e.g. case getType(increment): return { ... }
10+
/* ADVANCED API */
11+
12+
// More flexible allowing to create complex actions more easily
13+
// use can use "action-creator" instance in place of "type constant"
14+
// e.g. case getType(increment): return action.payload;
1115
// This will allow to completely eliminate need for "constants" in your application, more info here:
1216
// https://github.com/piotrwitek/typesafe-actions#constants
1317

14-
// OPTION 1 (with generics):
15-
// import { createStandardAction } from 'typesafe-actions';
16-
// export const increment = createStandardAction(INCREMENT)<void>();
17-
// export const add = createStandardAction(ADD)<number>();
18-
19-
// OPTION 2 (with resolve callback):
20-
// import { createAction } from 'typesafe-actions';
21-
// export const increment = createAction(INCREMENT);
22-
// export const add = createAction(ADD, resolve => {
23-
// return (amount: number) => resolve(amount);
24-
// });
18+
import { createAction } from 'typesafe-actions';
19+
import { Todo } from '../todos/models';
20+
21+
export const emptyAction = createAction(INCREMENT)<void>();
22+
export const payloadAction = createAction(ADD)<number>();
23+
export const payloadMetaAction = createAction(ADD)<number, string>();
24+
25+
export const payloadCreatorAction = createAction(
26+
'TOGGLE_TODO',
27+
(todo: Todo) => todo.id
28+
)<string>();

0 commit comments

Comments
 (0)