-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
54 lines (54 loc) · 1.4 KB
/
App.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
43
44
45
46
47
48
49
50
51
52
53
54
import React, { Component } from 'react'
export default class App extends Component {
constructor(props) {
super(props)
this.state = {
data: [],
page: 0
}
}
componentDidMount() {
this.setState(state => {
state.data = this.props.txs.slice(0, 50)
return state
})
window.addEventListener('scroll', () => {
if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight) {
console.log("you're at the bottom of the page");
const page = this.state.page + 1
this.setState(state => {
state.page = page
state.data = state.data.concat(this.props.txs.slice(page * 50, page * 50 + 50))
return state
})
}
})
}
componentWillUnmount() {
console.log('unmounting')
window.removeEventListener('scroll')
}
render() {
console.log('this.state.data', this.state.data)
return(
this.state.data.flatMap((tx, i) => {
const videos = tx.out
.filter(xput => Boolean(xput.f3) === true)
.map(xput => xput.f3)
.map(f3 => {
return (
<img
key={i}
width={300}
align={'middle'}
height={200}
style={{ margin: 10 }}
src={`http://x.bitfs.network/${f3}`}
/>
)
})
return videos
})
)
}
}