小编pav*_*nan的帖子

如何修复类型无法分配给 React router render prop 的 LibraryManagedAttributes

我最近将所有反应库更新为最新版本及其所有类型。我面临打字稿编译的问题。它是在说

[ts] Type '{ history: History<any>; location: Location<any>; match: match<any>; staticContext?: StaticContext; }' is not assignable to type 'LibraryManagedAttributes<T["component"], Readonly<{ children?: ReactNode; }> & Readonly<{ history: History<any>; location: Location<any>; match: match<any>; staticContext?: StaticContext; }>>'. [2322]
Run Code Online (Sandbox Code Playgroud)
type PrivateRouteProps = UserAuthStore.UserAuthState &
    typeof UserAuthStore.actionCreators &
    RouteProps &
    { component: typeof React.Component };

class PrivateRoute<T extends PrivateRouteProps = PrivateRouteProps> extends React.Component<T, {}> {


    render() {

        let auth = new Auth();

        const {
            isAuthenticated,
            component: Component,
            ...props
        } = this.props

        if (!isAuthenticated) {
            console.log(this.props) …
Run Code Online (Sandbox Code Playgroud)

reactjs react-router typescript3.0

5
推荐指数
1
解决办法
5323
查看次数

java中实例化子类时会自动调用父类构造函数

abstract class A {
    abstract void method();
}

class B extends A {
    B() {
    }

    void method() {
    }
}

class C extends B {
    C() {
    }
}
Run Code Online (Sandbox Code Playgroud)

当我在 main 中实例化类 C 时,它会自动调用 B(父类)的构造函数。这是正常现象还是我做错了什么?

java

-5
推荐指数
1
解决办法
1万
查看次数

标签 统计

java ×1

react-router ×1

reactjs ×1

typescript3.0 ×1