VirtualList

Summary: _typescript_

Reviewed By: bnelo12

Differential Revision: D16830546

fbshipit-source-id: cd3caa4a37bb9abaf7c23c58d90d61c5e32cea08
This commit is contained in:
Daniel Büchele
2019-08-20 03:18:32 -07:00
committed by Facebook Github Bot
parent 115e2b3576
commit 726b9cb141
2 changed files with 30 additions and 26 deletions

View File

@@ -5,21 +5,25 @@
* @format * @format
*/ */
import FlexColumn from './FlexColumn.js'; import FlexColumn from './FlexColumn';
import {Component} from 'react'; import {Component} from 'react';
import View from './View.tsx'; import View from './View';
import styled from '../styled/index.js'; import styled from 'react-emotion';
import React from 'react';
import {HeightProperty, TopProperty} from 'csstype';
const Inner = styled(FlexColumn)(({height}) => ({ const Inner = styled(FlexColumn)(
alignItems: 'flex-start', ({height}: {height: HeightProperty<number>}) => ({
height, alignItems: 'flex-start',
minHeight: '100%', height,
minWidth: '100%', minHeight: '100%',
overflow: 'visible', minWidth: '100%',
width: '100%', overflow: 'visible',
})); width: '100%',
}),
);
const Content = styled(FlexColumn)(({top}) => ({ const Content = styled(FlexColumn)(({top}: {top: TopProperty<number>}) => ({
alignItems: 'flex-start', alignItems: 'flex-start',
height: '100%', height: '100%',
marginTop: top, marginTop: top,
@@ -27,23 +31,23 @@ const Content = styled(FlexColumn)(({top}) => ({
overflow: 'visible', overflow: 'visible',
})); }));
type VirtualListProps = {| type VirtualListProps = {
data: Array<any>, data: Array<any>;
renderRow: (data: any, i: number) => any, renderRow: (data: any, i: number) => any;
rowHeight: number, rowHeight: number;
overscanCount: number, overscanCount: number;
sync?: number, sync?: boolean;
wrapInner?: (data: any) => any, wrapInner?: (data: any) => any;
|}; };
type VirtualListState = {| type VirtualListState = {
offset: number, offset: number;
height: number, height: number;
|}; };
export default class VirtualList extends Component< export default class VirtualList extends Component<
VirtualListProps, VirtualListProps,
VirtualListState, VirtualListState
> { > {
constructor(props: VirtualListProps, context: Object) { constructor(props: VirtualListProps, context: Object) {
super(props, context); super(props, context);

View File

@@ -88,7 +88,7 @@ export {default as ErrorBoundary} from './components/ErrorBoundary.js';
export type {OrderableOrder} from './components/Orderable.tsx'; export type {OrderableOrder} from './components/Orderable.tsx';
export {default as Interactive} from './components/Interactive.js'; export {default as Interactive} from './components/Interactive.js';
export {default as Orderable} from './components/Orderable.tsx'; export {default as Orderable} from './components/Orderable.tsx';
export {default as VirtualList} from './components/VirtualList.js'; export {default as VirtualList} from './components/VirtualList.tsx';
// base components // base components
export {Component, PureComponent} from 'react'; export {Component, PureComponent} from 'react';