Reputation: 547
I am trying to use Polymorphism for React components w/ inheritance, but I am seeing "This type is incompatible with some incompatible instantiation of V" error.
Here is the code:
// @flow
import React, { Component } from 'react'
type BaseProps = {
name: string
}
type BaseState<T> = {
error: string,
value: ?T,
}
class Base<Props, V> extends Component<any, BaseProps & Props, BaseState<V>> {
state = {
error: '',
value: null,
}
render() {
return <div>this.props.name</div>
}
}
type ExtendedProps = {
foo: string,
}
class ExtendedBase extends Base<ExtendedProps, string> {
render () {
return <div>this.props.name</div>
}
}
What am I doing wrong?
Upvotes: 2
Views: 223