react-keep-scrolling
v0.0.11
Published
react-keep-scrolling React component
Downloads
4
Readme
react-keep-scrolling
Instalation
- npm install react-keep-scrolling --save
- yarn add react-keep-scrolling
Usage
properties
- before
- getMore
- initialLoad
before
cals your getMore function before hitting the bottom of the bage by that value default is 200
getMore
the function that will be called when the scroll happens
initialLoad
load the data when initializing
import React, {Component} from 'react'
import {render} from 'react-dom'
import ReactKeepScrolling from 'react-keep-scrolling'
class Demo extends Component {
constructor(props){
super(props)
this.state ={
numbers : '1234567890-3456789oqweqe908qwe'.split('')
}
}
getMore(){
this.setState({
numbers: [...this.state.numbers, Math.random() * 1000]
})
}
render() {
const numbersLi = this.state.numbers.map((item, idx) => (<li key={idx}>{item}</li>))
const getMore = this.getMore.bind(this)
return <div>
<span>we</span>
<ul>
<ReactKeepScrolling before={100} getMore={getMore}>
{numbersLi}
</ReactKeepScrolling>
</ul>
</div>
}
}
render(<Demo/>, document.querySelector('#demo'))
Describe react-keep-scrolling here.