use $ReadOnlyArray for section stuff

Reviewed By: kassens

Differential Revision: D4983581

fbshipit-source-id: 7951b6d225aee62932ac12047afb89a34fc58722
This commit is contained in:
Spencer Ahrens 2017-05-03 10:18:26 -07:00 коммит произвёл Facebook Github Bot
Родитель 9a2d6da8bb
Коммит 5084e1ba0f
2 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -25,7 +25,7 @@ type SectionBase<SectionItemT> = {
/** /**
* The data for rendering items in this section. * The data for rendering items in this section.
*/ */
data: Array<SectionItemT>, data: $ReadOnlyArray<SectionItemT>,
/** /**
* Optional key to keep track of section re-ordering. If you don't plan on re-ordering sections, * 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. * the array index will be used by default.
@ -56,13 +56,13 @@ type RequiredProps<SectionT: SectionBase<any>> = {
* *
* General shape: * General shape:
* *
* sections: Array<{ * sections: $ReadOnlyArray<{
* data: Array<SectionItem>, * data: $ReadOnlyArray<SectionItem>,
* renderItem?: ({item: SectionItem, ...}) => ?React.Element<*>, * renderItem?: ({item: SectionItem, ...}) => ?React.Element<*>,
* ItemSeparatorComponent?: ?ReactClass<{highlighted: boolean, ...}>, * ItemSeparatorComponent?: ?ReactClass<{highlighted: boolean, ...}>,
* }> * }>
*/ */
sections: Array<SectionT>, sections: $ReadOnlyArray<SectionT>,
}; };
type OptionalProps<SectionT: SectionBase<any>> = { type OptionalProps<SectionT: SectionBase<any>> = {

Просмотреть файл

@ -25,7 +25,7 @@ type SectionItem = any;
type SectionBase = { type SectionBase = {
// Must be provided directly on each section. // Must be provided directly on each section.
data: Array<SectionItem>, data: $ReadOnlyArray<SectionItem>,
key?: string, key?: string,
// Optional props will override list-wide props just for this section. // Optional props will override list-wide props just for this section.
@ -49,7 +49,7 @@ type SectionBase = {
}; };
type RequiredProps<SectionT: SectionBase> = { type RequiredProps<SectionT: SectionBase> = {
sections: Array<SectionT>, sections: $ReadOnlyArray<SectionT>,
}; };
type OptionalProps<SectionT: SectionBase> = { type OptionalProps<SectionT: SectionBase> = {
@ -120,7 +120,7 @@ export type Props<SectionT> =
OptionalProps<SectionT> & OptionalProps<SectionT> &
VirtualizedListProps; VirtualizedListProps;
type DefaultProps = (typeof VirtualizedList.defaultProps) & {data: Array<Item>}; type DefaultProps = (typeof VirtualizedList.defaultProps) & {data: $ReadOnlyArray<Item>};
type State = {childProps: VirtualizedListProps}; type State = {childProps: VirtualizedListProps};
/** /**
@ -413,7 +413,7 @@ class ItemWithSeparator extends React.Component {
} }
} }
function getItem(sections: ?Array<Item>, index: number): ?Item { function getItem(sections: ?$ReadOnlyArray<Item>, index: number): ?Item {
if (!sections) { if (!sections) {
return null; return null;
} }