I try to do infinite scroll by detecting the items are different in componentWillReceiveprops
, like so
componentWillReceiveprops(nextProps) {
//if infinite load triggered
if(!isEqual(nextProps.items, this.props.items)){
this.props.items.push(...nextProps.items)
//this.forceUpdate()
console.log(this.props.items) // newly items are merge with previous items array, worked.
}
}
render() {
const { items } = this.props
console.log(items) // still old items, newly loaded items is not here?
return(<div></div>)
}
But items
in my render method and the items
in componentWillReceiveprops
is not the same? I also tried forceUpdate
still coulnd't make this infinite scroll work.