goldenyz / react-perfect-scrollbar

A react wrapper for perfect-scrollbar
MIT License
482 stars 92 forks source link

onYReachEnd errors "Maximum update depth exceeded” on load of page. #108

Open Justicism15 opened 4 years ago

Justicism15 commented 4 years ago

I am using onYReachEnd in the perfect scrollbar but everytime I load the page an error occurs "Maximum update depth exceeded”. I am using it to call the pagination function:

Code: <PerfectScrollbar swipeEasing={true} onYReachEnd={() => console.log("end")} onYReachStart={()=>this.handlePagination()} options={{ wheelSpeed: 1, wheelPropagation: true, minScrollbarLength: 20, }}

....items

giovanniKleinCampigoto commented 4 years ago

I'm having this problem too, is it from a recent version?

Justicism15 commented 4 years ago

I'm having this problem too, is it from a recent version?

Yes this is from the recent version. I still haven't solve the problem.

goldenyz commented 4 years ago

Could you show me what you have done in handlePagination

Justicism15 commented 4 years ago

Here is the code for handlePagination function:

handlePagination = () =>{ let currentPagination = this.state.currentPagination + 1 this.setState(prevState =>{ return{ ...prevState, currentPagination : prevState.currentPagination + 1, initialLoad : false, } })

this.props.getSpecificChatThread(this.state.threadId).then((response) => { if (!isNullOrUndefined(response) && API_ERROR_STATUS === response.status) { this.setState({ isErrorModalShow: true }) } else { if(this.props.threadMessages.length > 0){ this.setState({ itemCount : this.props.threadMessages.length, }) } } }) }

Tonysmark commented 4 years ago
<PerfectScrollbar
onYReachEnd={() => this.setState({ nextPage:2 })}
>

and it will setState over and over again

azeveco commented 4 years ago

I am using onYReachEnd in the perfect scrollbar but everytime I load the page an error occurs "Maximum update depth exceeded”. I am using it to call the pagination function:

Code: <PerfectScrollbar swipeEasing={true} onYReachEnd={() => console.log("end")} onYReachStart={()=>this.handlePagination()} options={{ wheelSpeed: 1, wheelPropagation: true, minScrollbarLength: 20, }}

....items

Hello! I'm trying to do the same with this onYReachStart.

One question for you about that: how do you set the scrollbar to start at the end always? Mine starts at the start (top) and then goes to the bottom. Because of this behaviour the onReachYStart fires in the first load

tokomeno-kaltura commented 3 years ago

Any updates on the issue?

Having the same issue, onYReachEnd is calling the infinity after page load