[英]How do I inherit class with FlowType?
Use React(ReactNative). 使用React(ReactNative)。
Want to inherit Component class, but in that case happen trouble with flow error. 要继承Component类,但在这种情况下会发生流错误的麻烦。
/* @flow */
import React, { Component } from 'react';
import { Text, View } from 'react-native';
type commonProps ={
actions: Object,
};
type someProps = commonProps & {
someNumber: number,
};
class CustomComponent extends Component<commonProps> {
static defaultProps: {};
props: commonProps;
}
class MyComponent extends CustomComponent {
props: someProps;
render() {
return (
<Text>{this.props.someNumber}</Text>
);
}
}
What to do??? 该怎么办???
I guess you should set type annotation for classes. 我猜你应该为类设置类型注释。 Like this:
像这样:
class CustomComponent<commonProps> extends Component<Props, State> {
static defaultProps: {};
props: commonProps;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.