From 5084e1ba0fcfc6409898d746086629011e7134da Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Wed, 3 May 2017 10:18:26 -0700 Subject: [PATCH] use $ReadOnlyArray for section stuff Reviewed By: kassens Differential Revision: D4983581 fbshipit-source-id: 7951b6d225aee62932ac12047afb89a34fc58722 --- Libraries/Lists/SectionList.js | 8 ++++---- Libraries/Lists/VirtualizedSectionList.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Libraries/Lists/SectionList.js b/Libraries/Lists/SectionList.js index e96c0c02e4..f45936b936 100644 --- a/Libraries/Lists/SectionList.js +++ b/Libraries/Lists/SectionList.js @@ -25,7 +25,7 @@ type SectionBase = { /** * The data for rendering items in this section. */ - data: Array, + data: $ReadOnlyArray, /** * Optional key to keep track of section re-ordering. If you don't plan on re-ordering sections, * the array index will be used by default. @@ -56,13 +56,13 @@ type RequiredProps> = { * * General shape: * - * sections: Array<{ - * data: Array, + * sections: $ReadOnlyArray<{ + * data: $ReadOnlyArray, * renderItem?: ({item: SectionItem, ...}) => ?React.Element<*>, * ItemSeparatorComponent?: ?ReactClass<{highlighted: boolean, ...}>, * }> */ - sections: Array, + sections: $ReadOnlyArray, }; type OptionalProps> = { diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index 9ab31b2807..52c49daaf3 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -25,7 +25,7 @@ type SectionItem = any; type SectionBase = { // Must be provided directly on each section. - data: Array, + data: $ReadOnlyArray, key?: string, // Optional props will override list-wide props just for this section. @@ -49,7 +49,7 @@ type SectionBase = { }; type RequiredProps = { - sections: Array, + sections: $ReadOnlyArray, }; type OptionalProps = { @@ -120,7 +120,7 @@ export type Props = OptionalProps & VirtualizedListProps; -type DefaultProps = (typeof VirtualizedList.defaultProps) & {data: Array}; +type DefaultProps = (typeof VirtualizedList.defaultProps) & {data: $ReadOnlyArray}; type State = {childProps: VirtualizedListProps}; /** @@ -413,7 +413,7 @@ class ItemWithSeparator extends React.Component { } } -function getItem(sections: ?Array, index: number): ?Item { +function getItem(sections: ?$ReadOnlyArray, index: number): ?Item { if (!sections) { return null; }