diff --git a/Libraries/Lists/SectionList.js b/Libraries/Lists/SectionList.js index e96c0c02e..f45936b93 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 9ab31b280..52c49daaf 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; }