-
Notifications
You must be signed in to change notification settings - Fork 295
/
SimpleTransactionList.tsx
53 lines (49 loc) · 1.41 KB
/
SimpleTransactionList.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// @flow
import React, { Component } from 'react';
import type { Node } from 'react';
import { observer } from 'mobx-react';
import type { Row } from '../types';
import type { ScrollContextType } from '../WalletTransactionsList';
import { WalletTransactionsListScrollContext } from '../WalletTransactionsList';
import styles from './SimpleTransactionList.scss';
type Props = {
renderRow: (Row) => Node,
rows: Row[],
};
@observer
export class SimpleTransactionList extends Component<Props> {
static defaultProps = {
onOpenExternalLink: () => {},
};
onListScroll = (
context: ScrollContextType,
evt: SyntheticEvent<HTMLElement>
) => {
const { scrollTop } = evt.currentTarget;
if (scrollTop > 10) {
context.setIsScrolling(true);
} else {
context.setIsScrolling(false);
}
};
render() {
const { rows, renderRow } = this.props;
return (
<WalletTransactionsListScrollContext.Consumer>
{(context) => (
<div
className={styles.component}
onScroll={(evt) => this.onListScroll(context, evt)}
>
{rows.map((row, index) => (
// eslint-disable-next-line react/no-array-index-key
<div key={`simple-transaction-list-row-${index}`}>
{renderRow(row)}
</div>
))}
</div>
)}
</WalletTransactionsListScrollContext.Consumer>
);
}
}