所以我们想要的是:
在iOS中,我们可以为每个单元格类型使用多个cellIdentifier来创建高性能列表视图.
我现在拥有的是什么
render() {
const dataBlob = [
{ type: "address", data: { address, gotoEditAddress } },
{ type: "deliveryTime", data: {...} },
{ type: "cartSummary", data: {...} },
...[items.map(item => {{ type: "item", data: {...} }})],
{ type: "paymentInformation", data: {...} },
{ type: "paymentBreakdown", data: {...} },
{ type: "promoCode", data: {...} },
];
this._dataSource = this._dataSource.cloneWithRows(dataBlob);
return (
renderRow={this._renderRow}
dataSource={this._dataSource} />
);
)
并在renderRow方法上
_renderRow = (rowData) => {
const { type, data } = rowData;
if (type === "address") return ;
if (type === "deliveryTime") return ;
if (type === "menuItem") return ;
if (type === "cartSummary") return ;
if (type === "promoCode") return ;
if (type === "paymentInformation") return ;
if (type === "paymentBreakdown") return ;
return null;
};
上面代码的问题在于它使dataSource.rowHasChanged方法真正复杂,无法正确实现.
由于某种原因,当我删除一行时,在RN0.31中你会有一些ui缺陷: