Skip to content

Commit cb621ed

Browse files
committed
support redux 5.0
1 parent 2bf677a commit cb621ed

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"prettier": "^3.1.1",
7070
"react": "^18.2.0",
7171
"react-dom": "^18.2.0",
72-
"redux": "^4.2.1",
72+
"redux": "^5.0.0",
7373
"rimraf": "^5.0.5",
7474
"ts-jest": "^29.1.1",
7575
"ts-node": "^10.9.2",

src/actions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Location, Action, History } from 'history';
2+
import type { AnyAction } from 'redux';
23

34
export const CALL_HISTORY_METHOD = '@@router/CALL_HISTORY_METHOD';
45
export const LOCATION_CHANGE = '@@router/LOCATION_CHANGE';
@@ -23,7 +24,7 @@ export interface LocationActionPayload<A = unknown[]> {
2324
args?: A;
2425
}
2526

26-
export interface CallHistoryMethodAction<A = unknown[]> {
27+
export interface CallHistoryMethodAction<A = unknown[]> extends AnyAction {
2728
type: typeof CALL_HISTORY_METHOD;
2829
payload: LocationActionPayload<A>;
2930
}

src/middleware.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ function appendBasename(location: string | Location, basename: string): string |
2626
export const createRouterMiddleware =
2727
({ history, showHistoryAction, basename }: CreateRouterMiddlewareArgs): Middleware =>
2828
() =>
29+
// @ts-ignore
2930
(next: Dispatch) =>
3031
(action: ReduxAction) => {
3132
if (action.type !== CALL_HISTORY_METHOD) {
3233
return next(action);
3334
}
35+
// @ts-ignore
3436
const method = action.payload.method as HistoryMethods;
3537
// @ts-ignore
3638
const args = action.payload.args as Parameters<History[HistoryMethods]>;

src/reducer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ export const createRouterReducer = ({
2828

2929
return (state = initialState, { type, payload } = {} as AnyAction) => {
3030
if (type === LOCATION_CHANGE) {
31-
const { location, action } = payload || {};
31+
const { location, action } = (payload || {}) as {
32+
location?: Location | null;
33+
action?: Action | null;
34+
};
3235
const previousLocations = numLocationToTrack // @ts-ignore
3336
? [{ location, action }, ...state.previousLocations.slice(0, numLocationToTrack)]
3437
: undefined;

yarn.lock

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@
419419
dependencies:
420420
regenerator-runtime "^0.13.4"
421421

422-
"@babel/runtime@^7.12.5", "@babel/runtime@^7.9.2":
422+
"@babel/runtime@^7.12.5":
423423
version "7.16.0"
424424
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.16.0.tgz#e27b977f2e2088ba24748bf99b5e1dece64e4f0b"
425425
integrity sha512-Nht8L0O8YCktmsDV6FqFue7vQLRx3Hb0B37lS5y0jDRqRxlBG4wIJHnf9/bgSE2UyipKFA01YtS+npRdTWBUyw==
@@ -4386,12 +4386,10 @@ react@^18.2.0:
43864386
dependencies:
43874387
loose-envify "^1.1.0"
43884388

4389-
redux@^4.2.1:
4390-
version "4.2.1"
4391-
resolved "https://registry.yarnpkg.com/redux/-/redux-4.2.1.tgz#c08f4306826c49b5e9dc901dee0452ea8fce6197"
4392-
integrity sha512-LAUYz4lc+Do8/g7aeRa8JkyDErK6ekstQaqWQrNRW//MY1TvCEpMtpTWvlQ+FPbWCx+Xixu/6SHt5N0HR+SB4w==
4393-
dependencies:
4394-
"@babel/runtime" "^7.9.2"
4389+
redux@^5.0.0:
4390+
version "5.0.0"
4391+
resolved "https://registry.yarnpkg.com/redux/-/redux-5.0.0.tgz#29572e29a439e094ff8fec46883fc45053f6736d"
4392+
integrity sha512-blLIYmYetpZMET6Q6uCY7Jtl/Im5OBldy+vNPauA8vvsdqyt66oep4EUpAMWNHauTC6xa9JuRPhRB72rY82QGA==
43954393

43964394
reflect.getprototypeof@^1.0.4:
43974395
version "1.0.4"

0 commit comments

Comments
 (0)