use $ReadOnlyArray for section stuff
Reviewed By: kassens Differential Revision: D4983581 fbshipit-source-id: 7951b6d225aee62932ac12047afb89a34fc58722
This commit is contained in:
parent
9a2d6da8bb
commit
5084e1ba0f
|
@ -25,7 +25,7 @@ type SectionBase<SectionItemT> = {
|
|||
/**
|
||||
* 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,
|
||||
* the array index will be used by default.
|
||||
|
@ -56,13 +56,13 @@ type RequiredProps<SectionT: SectionBase<any>> = {
|
|||
*
|
||||
* General shape:
|
||||
*
|
||||
* sections: Array<{
|
||||
* data: Array<SectionItem>,
|
||||
* sections: $ReadOnlyArray<{
|
||||
* data: $ReadOnlyArray<SectionItem>,
|
||||
* renderItem?: ({item: SectionItem, ...}) => ?React.Element<*>,
|
||||
* ItemSeparatorComponent?: ?ReactClass<{highlighted: boolean, ...}>,
|
||||
* }>
|
||||
*/
|
||||
sections: Array<SectionT>,
|
||||
sections: $ReadOnlyArray<SectionT>,
|
||||
};
|
||||
|
||||
type OptionalProps<SectionT: SectionBase<any>> = {
|
||||
|
|
|
@ -25,7 +25,7 @@ type SectionItem = any;
|
|||
|
||||
type SectionBase = {
|
||||
// Must be provided directly on each section.
|
||||
data: Array<SectionItem>,
|
||||
data: $ReadOnlyArray<SectionItem>,
|
||||
key?: string,
|
||||
|
||||
// Optional props will override list-wide props just for this section.
|
||||
|
@ -49,7 +49,7 @@ type SectionBase = {
|
|||
};
|
||||
|
||||
type RequiredProps<SectionT: SectionBase> = {
|
||||
sections: Array<SectionT>,
|
||||
sections: $ReadOnlyArray<SectionT>,
|
||||
};
|
||||
|
||||
type OptionalProps<SectionT: SectionBase> = {
|
||||
|
@ -120,7 +120,7 @@ export type Props<SectionT> =
|
|||
OptionalProps<SectionT> &
|
||||
VirtualizedListProps;
|
||||
|
||||
type DefaultProps = (typeof VirtualizedList.defaultProps) & {data: Array<Item>};
|
||||
type DefaultProps = (typeof VirtualizedList.defaultProps) & {data: $ReadOnlyArray<Item>};
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue