Typescript 分项清单及;打字稿

Typescript 分项清单及;打字稿,typescript,react-native,react-native-sectionlist,Typescript,React Native,React Native Sectionlist,键入SectionList的正确方法是什么?我遇到了一个这样做的bug(来自): {item} renderSectionHeader={({section:{title}}})=>( {title} )} 节={ticksData} keyExtractor={(项,索引)=>item+index} />; 但这并不是: const renderSectionHeader=({section: {title}}) => ( <Text style={{fontWeight:

键入SectionList的正确方法是什么?我遇到了一个这样做的bug(来自):

{item}
renderSectionHeader={({section:{title}}})=>(
{title}
)}
节={ticksData}
keyExtractor={(项,索引)=>item+index}
/>;
但这并不是:

const renderSectionHeader=({section: {title}}) => (
  <Text style={{fontWeight: 'bold'}}>{title}</Text>
 );

return (
        <SectionList
          renderItem={({item, index}) => <Text key={index}>{item}</Text>}
          renderSectionHeader={renderSectionHeader}
          sections={ticksData}
          keyExtractor={(item, index) => item + index}
        />;
constrendersectionheader=({section:{title}})=>(
{title}
);
返回(
{item}
renderSectionHeader={renderSectionHeader}
节={ticksData}
keyExtractor={(项,索引)=>item+index}
/>;
我得到这个错误:

属性“renderSectionHeader”的类型不兼容。类型“({section:{title}}:{section:{title:any;};})=>Element”不可分配给类型“(信息:{section:SectionListData;})=>ReactElement”。参数类型“u 0”和“info”不兼容。类型“{section:SectionListData;}”不可分配给类型“{section:{title:any;};}。属性“section”的类型不兼容。类型“SectionListData”不能分配给类型“{title:any;}”。类型“SectionListData”中缺少属性“title”


有同样的问题,得出了这个答案,但还没有解决方案,所以这是我的:

import { SectionList, SectionListData } from 'react-native';

interface IHeader {
  section: SectionListData<{ title: string }>
}

const renderSectionHeader=({section: {title}}: IHeader) => (
  <Text style={{fontWeight: 'bold'}}>{title}</Text>
);
从'react native'导入{SectionList,SectionListData};
接口IHeader{
节:节列表数据
}
const renderSectionHeader=({section:{title}}}:IHeader)=>(
{title}
);
import { SectionList, SectionListData } from 'react-native';

interface IHeader {
  section: SectionListData<{ title: string }>
}

const renderSectionHeader=({section: {title}}: IHeader) => (
  <Text style={{fontWeight: 'bold'}}>{title}</Text>
);