Skip to content

Commit

Permalink
Merge pull request #77 from nicholas-l/fix-flow-type
Browse files Browse the repository at this point in the history
Add test and fix for flowtype for children
  • Loading branch information
bvaughn committed Oct 29, 2018
2 parents 70b66ae + e48ce2c commit 7960199
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/createGridComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ type RenderComponentProps<T> = {|
rowIndex: number,
style: Object,
|};
export type RenderComponent<T> = (props: RenderComponentProps<T>) => React$Node;
export type RenderComponent<T> = React$ComponentType<
$Shape<RenderComponentProps<T>>
>;

type ScrollDirection = 'forward' | 'backward';

Expand Down
2 changes: 1 addition & 1 deletion src/createListComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type RenderComponentProps<T> = {|
isScrolling?: boolean,
style: Object,
|};
type RenderComponent<T> = (props: RenderComponentProps<T>) => React$Node;
type RenderComponent<T> = React$ComponentType<$Shape<RenderComponentProps<T>>>;

type ScrollDirection = 'forward' | 'backward';

Expand Down
37 changes: 37 additions & 0 deletions src/test.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@ const assertCustomType = (value: ItemData) => {};
</VariableSizeList>;
}

{
class Item extends React.PureComponent<{ data: void }> {
render() {
const { data } = this.props;
assertVoid(data);
// $FlowFixMe itemData is undefined by default
assertEmpty(data);
return null;
}
}
<VariableSizeList width={0} height={0} itemSize={0} itemCount={0}>
{Item}
</VariableSizeList>;
}

/* FixedSizeGrid */

{
Expand Down Expand Up @@ -246,3 +261,25 @@ const assertCustomType = (value: ItemData) => {};
{Item}
</VariableSizeGrid>;
}

{
class Item extends React.PureComponent<{ data: void }> {
render() {
const { data } = this.props;
assertVoid(data);
// $FlowFixMe itemData is undefined by default
assertEmpty(data);
return null;
}
}
<VariableSizeGrid
width={0}
height={0}
rowHeight={0}
rowCount={0}
columnWidth={0}
columnCount={0}
>
{Item}
</VariableSizeGrid>;
}

0 comments on commit 7960199

Please sign in to comment.