使用React(ReactNative)。
想继承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>
);
}
}
该怎么办?
答案 0 :(得分:0)
我想您应该为类设置类型注释。像这样:
class CustomComponent<commonProps> extends Component<Props, State> {
static defaultProps: {};
props: commonProps;
}