我正在尝试使用 flow-bin 0.158.0 在 React-Native 0.66.1 上正确键入 SectionList 调用
我有以下代码:
// @flow
import React from 'react';
import type {Node} from 'react';
import {SafeAreaView, SectionList} from 'react-native';
type Props = {
sections: $ReadOnlyArray<{
title: string,
data: $ReadOnlyArray<{a: string}>,
}>,
};
const App: (props: Props) => Node = ({sections}) => {
return (
<SafeAreaView>
<SectionList sections={sections} renderItem={({item}) => null} />
</SafeAreaView>
);
};
export default App;
当我运行 flowjs 检查时,出现 20 个错误:
Cannot create SectionList element because property ItemSeparatorComponent is missing in object type [1] but exists in
SectionBase [2] in type argument SectionT. [prop-missing]
Cannot create SectionList element because property key is missing in object type [1] but exists in SectionBase [2] in
type argument SectionT. [prop-missing]
Cannot create SectionList element because property keyExtractor is missing in object type [1] but exists in
SectionBase [2] in type argument SectionT. [prop-missing]
Cannot create SectionList element because property renderItem is missing in object type [1] but exists in
SectionBase [2] in type argument SectionT. [prop-missing]
SectionBase 定义中的 key、renderItem、ItemSeparatorComponent 和 KeyExtractor 都设置为可选。
那么我的sections 道具的正确类型定义是什么?