Closed jpalumickas closed 1 year ago
Hey @jpalumickas. Thanks for pointing out the issue and it really makes sense to add an index
for the channel item which can be used in the ChannelPreview
component. We have added this to our backlog. Keep on following this card.
Hey team! Please add your planning poker estimate with ZenHub @Enigma-I-am @khushal87 @madsroskar @santhoshvai @vishalnarkhede
@jpalumickas we won't be able to prioritize this in near future. But you can use the following workaround:
import {
ChannelList,
ChannelPreview,
} from 'stream-chat-react-native';
const PreviewContext = React.createContext({});
<ChannelList
additionalFlatListProps={{
renderItem: ({ index, item }) => (
<PreviewContext.Provider data={{ index }}>
<ChannelPreview channel={item} Preview={CustomPreviewComponent} />
</PreviewContext.Provider>
),
}}
filters={filters}
/>
And within CustomPreviewComponent, use the PreviewContext consumer to access the index. Technically it should work
Motivation We need to know a position of Channel List item to show different style, so we can use
renderItem
index
for that, but currently it's not available in customChannelList
Preview
Proposed solution in
renderItem
we can getindex
which we can pass to custom PreviewAcceptance Criteria
index
is available in custom providedPreview