したがって、私たちが望むのは次のようなものです。
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 (
<ListView ref="ScrollView"
renderRow={this._renderRow}
dataSource={this._dataSource} />
);
)
および renderRow メソッドで
_renderRow = (rowData) => {
const { type, data } = rowData;
if (type === "address") return <AddressRow {...data} />;
if (type === "deliveryTime") return <DeliveryTimeRow {...data} />;
if (type === "menuItem") return <MenuItemRow {...data} />;
if (type === "cartSummary") return <CartSummaryRow {...data} />;
if (type === "promoCode") return <PromoCodeRow {...data} />;
if (type === "paymentInformation") return <PaymentRow {...data} />;
if (type === "paymentBreakdown") return <PaymentBreakdownRow {...data} />;
return null;
};
上記のコードの問題は、dataSource.rowHasChanged メソッドを正しく実装するのが非常に複雑になることです。
何らかの理由で行を削除すると、RN0.31 では次のようないくつかの ui-defects が発生します。