react-native-swipe-list-view
react-native-swipe-list-view copied to clipboard
SectionList typescript sections error
SectionListProps<ItemT, SectionT = DefaultSectionT>
Hey @hengkx what is the issue? Any chance you could submit a PR to fix? Thanks!
@jemise111
I think @hengkx refer this problem:
when we use useSectionList
renderItem the argument should return follow object https://reactnative.dev/docs/sectionlist#requiredrenderitem
- 'item' (object) - the item object as specified in this section's data key
- 'index' (number) - Item's index within the section.
- 'section' (object) - The full section object as specified in sections.
- 'separators' (object) - An object with the following keys:
- 'highlight' (function) - () => void
- 'unhighlight' (function) - () => void
- 'updateProps' (function) - (select, newProps) => void
- 'select' (enum) - possible values are 'leading', 'trailing'
- 'newProps' (object)
<SwipeListView
useSectionList
renderItem={({item, section}) => { // TS Error: Property 'section' does not exist on type 'ListRenderItemInfo '.
return <ItemShowingLayout item={item} />;
}}
/>
That's correct as i'm facing the same exact issue as described by @tmirun, while waiting for a fix. Is there a short term fix to convert the data from ListRenderItemInfo
to SectionListRenderItemInfo
. Something like:
<SwipeListView
{...props}
useSectionList
renderItem={(data, rowMap): ReactElement => {
const sectionData = { ...data } as SectionListRenderItemInfo<T> //<---- Something like this?
return renderItem({ sectionData, rowMap })
}
}
/>
then in your renderItem()
can specify the type to be SectionListRenderItemInfo<T>
instead