Listview 虚拟化列表组件分隔符
我似乎找不到在VirtualizedList中处理/添加分隔符的任何道具,那么如何为VirtualizedList添加自己的分隔符组件呢?还是我必须使用平面列表Listview 虚拟化列表组件分隔符,listview,react-native,Listview,React Native,我似乎找不到在VirtualizedList中处理/添加分隔符的任何道具,那么如何为VirtualizedList添加自己的分隔符组件呢?还是我必须使用平面列表 注意:我希望避免使用FlatList,因为传入的数据是不可变的类型。您可以创建自己的分隔符组件,并基于元素类型映射呈现元素 const separatorComp = fromJS([ key: 'some-uniq-key', type: rowType.separator, ]); const Separator = (
注意:我希望避免使用FlatList,因为传入的数据是不可变的类型。您可以创建自己的分隔符组件,并基于元素类型映射呈现元素
const separatorComp = fromJS([
key: 'some-uniq-key', type: rowType.separator,
]);
const Separator = ({ <if needed to pass some props> }) => {
<br><br> <Some kind of separator or something maybe your own component>
};
const rowTypes = {
separator: 0,
};
const typeElementHash = {
[rowTypes.separator]: Separator;
}
const baseRowRenderer = ({
cellMeasurerCache,
virtualizedList,
...props
}) => ({ index, parent, style }) => {
const data = virtualizedList.get(index);
const key = data.get('key');
const Element = typeElementHash[data.get('type')];
return (
<CellMeasurer
key={key}
cache={cellMeasurerCache}
columnIndex={0}
parent={parent}
rowIndex={index}
>
<div style={style}>
<Element {...props} data={data} index={index} />
</div>
</CellMeasurer>
);
};
const separatorComp=fromJS([
key:'some uniq key',type:rowType.separator,
]);
常量分隔符=({})=>{
};
常量行类型={
分隔符:0,
};
常量typeElementHash={
[行类型.分隔符]:分隔符;
}
常量baseRowRenderer=({
CellMeasureCache,
虚拟化列表,
…道具
})=>({index,parent,style})=>{
const data=virtualizedList.get(索引);
const key=data.get('key');
const Element=typeElementHash[data.get('type');
返回(
);
};