-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
42 lines (33 loc) · 907 Bytes
/
index.js
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
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { getMostActive } from '../../store/actions/'
import { preLoad } from '../../helpers/preLoad'
import List from '../List'
class MostActive extends Component {
onRefresh = () => this.props.getMostActive()
componentDidUpdate = prevProps => {
const { mostActive, tabs } = this.props
if (tabs.index !== prevProps.tabs.index) {
if (mostActive.loading === null && preLoad(5)) {
this.props.getMostActive()
}
}
}
render() {
const { data, loading } = this.props.mostActive
return (
<List header="MOST ACTIVE" loading={loading} list={data} />
)
}
}
const mapStateToProps = state => ({
mostActive: state.mostActive,
tabs: state.tab
})
const mapDispatchToProps = {
getMostActive
}
export default connect(
mapStateToProps,
mapDispatchToProps
)(MostActive)