0

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 がすべてオプションに設定されています。

では、セクション プロップの正しい型定義は何でしょうか?

4

0 に答える 0