-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathEventsTableVirtualized.js
More file actions
55 lines (49 loc) · 1.56 KB
/
EventsTableVirtualized.js
File metadata and controls
55 lines (49 loc) · 1.56 KB
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
54
55
import React, { Component } from 'react'
import {connect} from 'react-redux'
import {fetchAllEvents, selectEvent, eventListSelector, loadedSelector, loadingSelector} from '../../ducks/events'
import Loader from '../common/Loader'
import {Table, Column, InfiniteLoader} from 'react-virtualized'
import 'react-virtualized/styles.css'
export class EventsTableVirtualized extends Component {
static propTypes = {
};
componentDidMount() {
this.props.fetchAllEvents()
}
render() {
if (this.props.loading) return <Loader />
return (
<Table
height={500}
width={400}
rowHeight={40}
overscanRowCount={0}
rowGetter={this.rowGetter}
rowCount={this.props.events.length}
headerHeight={50}
>
<Column
dataKey="title"
width={200}
label="title"
/>
<Column
dataKey="when"
width={100}
label="month"
/>
<Column
dataKey="where"
width={200}
label="place"
/>
</Table>
)
}
rowGetter = ({ index }) => this.props.events[index]
}
export default connect((state) => ({
events: eventListSelector(state),
loading: loadingSelector(state),
loaded: loadedSelector(state)
}), { fetchAllEvents, selectEvent })(EventsTableVirtualized)