Skip to content

Commit 44773b1

Browse files
incertapiotrwitek
authored andcommitted
Replace deprecated modules in playground (piotrwitek#176)
Replace 'react-router-redux' with 'connected-react-router' Also I noticed a lot of vulnerability warnings related to react-scripts, so I had update it and also react-redux, axios. For now we don't have vulnerability complains after npm i. @babel/polyfill is deprecated for the new react-scripts environment, so I remove this dependency and adjust src/index.tsx
1 parent 439f5b8 commit 44773b1

File tree

9 files changed

+4117
-7812
lines changed

9 files changed

+4117
-7812
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ import { StateType, ActionType } from 'typesafe-actions';
10791079
declare module 'MyTypes' {
10801080
export type Store = StateType<typeof import('./index').default>;
10811081
export type RootAction = ActionType<typeof import('./root-action').default>;
1082-
export type RootState = StateType<typeof import('./root-reducer').default>;
1082+
export type RootState = StateType<ReturnType<typeof import('./root-reducer').default>>;
10831083
}
10841084

10851085
declare module 'typesafe-actions' {
@@ -1101,6 +1101,7 @@ When creating a store instance we don't need to provide any additional types. It
11011101
import { RootAction, RootState, Services } from 'MyTypes';
11021102
import { createStore, applyMiddleware } from 'redux';
11031103
import { createEpicMiddleware } from 'redux-observable';
1104+
import { createBrowserHistory } from 'history';
11041105

11051106
import { composeEnhancers } from './utils';
11061107
import rootReducer from './root-reducer';
@@ -1124,8 +1125,11 @@ const enhancer = composeEnhancers(applyMiddleware(...middlewares));
11241125
// rehydrate state on app start
11251126
const initialState = {};
11261127

1128+
// browser history
1129+
const history = createBrowserHistory();
1130+
11271131
// create store
1128-
const store = createStore(rootReducer, initialState, enhancer);
1132+
const store = createStore(rootReducer(history), initialState, enhancer);
11291133

11301134
epicMiddleware.run(rootEpic);
11311135

playground/package-lock.json

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

playground/package.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,23 @@
1919
"tsc:watch": "tsc -p ./ --noEmit -w"
2020
},
2121
"dependencies": {
22-
"@babel/polyfill": "7.4.4",
2322
"@types/jest": "24.0.11",
2423
"@types/node": "11.13.8",
2524
"@types/prop-types": "15.7.1",
2625
"@types/react": "16.8.14",
2726
"@types/react-dom": "16.8.4",
2827
"@types/react-redux": "7.0.8",
2928
"@types/react-router-dom": "4.3.2",
30-
"@types/react-router-redux": "5.0.18",
31-
"axios": "0.18.0",
29+
"axios": "^0.19.0",
30+
"connected-react-router": "6.5.0",
3231
"cuid": "2.1.6",
3332
"prop-types": "15.7.2",
3433
"react": "16.8.6",
3534
"react-dom": "16.8.6",
36-
"react-redux": "7.0.2",
35+
"react-redux": "7.1.0",
3736
"react-redux-typescript-scripts": "1.5.0",
3837
"react-router-dom": "4.3.1",
39-
"react-router-redux": "5.0.0-alpha.8",
40-
"react-scripts": "2.1.8",
38+
"react-scripts": "3.0.1",
4139
"react-testing-library": "7.0.0",
4240
"redux": "4.0.1",
4341
"redux-observable": "1.1.0",

playground/src/components/error-message.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const ErrorMessage: React.FC<{ onReset: () => void }> = ({
88
<h2>{`Sorry there was an unexpected error`}</h2>
99
{`To continue: `}
1010
<a
11+
href="/"
1112
onClick={() => {
1213
onReset();
1314
}}

playground/src/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
// tslint:disable-next-line:no-import-side-effect
2-
import '@babel/polyfill';
3-
// tslint:disable-next-line:no-import-side-effect
42
import 'tslib';
53
// tslint:disable-next-line:no-import-side-effect
64
import './index.css';

playground/src/store/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { RootAction, RootState, Services } from 'MyTypes';
22
import { createStore, applyMiddleware } from 'redux';
33
import { createEpicMiddleware } from 'redux-observable';
4+
import { createBrowserHistory } from 'history';
45

56
import { composeEnhancers } from './utils';
67
import rootReducer from './root-reducer';
@@ -24,8 +25,11 @@ const enhancer = composeEnhancers(applyMiddleware(...middlewares));
2425
// rehydrate state on app start
2526
const initialState = {};
2627

28+
// browser history
29+
const history = createBrowserHistory();
30+
2731
// create store
28-
const store = createStore(rootReducer, initialState, enhancer);
32+
const store = createStore(rootReducer(history), initialState, enhancer);
2933

3034
epicMiddleware.run(rootEpic);
3135

playground/src/store/root-action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { routerActions } from 'react-router-redux';
1+
import { routerActions } from 'connected-react-router';
22
import * as todosActions from '../features/todos/actions';
33
import * as countersActions from '../features/counters/actions';
44

playground/src/store/root-reducer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { combineReducers } from 'redux';
2+
import { History } from 'history';
23

3-
import { routerReducer } from 'react-router-redux';
4+
import { connectRouter } from 'connected-react-router';
45
import todosReducer from '../features/todos/reducer';
56
import countersReducer from '../features/counters/reducer';
67

7-
const rootReducer = combineReducers({
8-
router: routerReducer,
8+
const rootReducer = (history: History) => combineReducers({
9+
router: connectRouter(history),
910
todos: todosReducer,
1011
counters: countersReducer,
1112
});

playground/src/store/types.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StateType, ActionType } from 'typesafe-actions';
33
declare module 'MyTypes' {
44
export type Store = StateType<typeof import('./index').default>;
55
export type RootAction = ActionType<typeof import('./root-action').default>;
6-
export type RootState = StateType<typeof import('./root-reducer').default>;
6+
export type RootState = StateType<ReturnType<typeof import('./root-reducer').default>>;
77
}
88

99
declare module 'typesafe-actions' {

0 commit comments

Comments
 (0)