Skip to content

Commit 60ae78a

Browse files
committed
[fix] @withRouter type compatibility
1 parent c1e5d10 commit 60ae78a

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-router-class-tools",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"license": "LGPL-3.0",
55
"author": "[email protected]",
66
"description": "Class Component utilities for React Router 6+",

source/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export const withRouter = <
9191
Class: C,
9292
context?: ClassDecoratorContext<C>
9393
) =>
94-
class ComponentWithRouter extends (Class as Constructor<Component<P>>) {
94+
class ComponentWithRouter extends (Class as Constructor<Component<P>> & C) {
9595
static WrappedComponent = Class;
9696
static displayName = `withRouter(${Class.displayName || Class.name})`;
9797

test/source/page/WithRouterDecorator.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { RouteComponentProps, withRouter } from '../../../source';
44

55
@withRouter
66
export class PageWithRouterDecorator extends Component<RouteComponentProps> {
7+
someMethod() {}
8+
79
render() {
810
const { location, match, query } = this.props;
911

0 commit comments

Comments
 (0)