This code:
/**
* @flow
*/
import React from 'react';
import {Text, View} from 'react-native';
class ParentClass extends React.Component {
textRender() {
throw ('Not Implemented!');
}
render() {
return <View>Parent: {this.textRender()}</View>;
}
}
class BasicSubclass extends ParentClass {
textRender() {
return <Text>Basic</Text>;
}
}
class SubclassWithState extends ParentClass {
state: {
data: number,
};
constructor(props: Object) {
super(props);
this.state = {
data: -1,
};
}
textRender() {
return <Text>State: {this.state.data}</Text>;
}
}
Gives the following errors:
test.js:9
9: class ParentClass extends React.Component {
^^^^^^^^^^^^^^^ undefined. Did you forget to declare type parameter `State` of property `Component`?. This type is incompatible with
31: state: {
^ object type
test.js:31
31: state: {
^ object type. This type is incompatible with
9: class ParentClass extends React.Component {
^^^^^^^^^^^^^^^ undefined. Did you forget to declare type parameter `State` of property `Component`?
@thejameskyle Is this intentional?
this simplified example does not work neither
/* @flow */
class ParentClass {
state: {
foo: string
}
}
class Subclass extends ParentClass {
state: {
foo: string,
bar: string
}
}
I met this problem too.
Closing in favour of https://github.com/facebook/flow/issues/1594
Most helpful comment
this simplified example does not work neither