score:4

Accepted answer

you can make parentcomponent generic as well so that the childcomponent can specify different props and state:

interface parentprops {
    something: string
}

interface parentstate {
    somethingelse: string
}

export class parentcomponent<tprops extends parentprops = parentprops, tstate extends parentstate = parentstate>
extends react.component<tprops, tstate> {

    // component logic.

    sharedfunction() {
        // some shared function.
    }
}

interface childprops {
    something: string
}

interface childstate {
    somethingelse: string
}

export class childcomponent extends parentcomponent<childprops, childstate> {
    // child component logic.
}

Related Query

More Query from same tag