You should use conditional rendering to solve this problem as well as executing both functions on the onClick event.
checkAllLoaded = () => {
if (this.state.data.length < this.state.VisibleNo)
this.setState(prevState => ({...prevState, LoadMoreVis: 'none'}));
}
handleClick = () => {
this.setState(prevState => ({...prevState, VisibleNo: this.state.VisibleNo+10}));
checkAllLoaded();
}
{this.state.LoadMoreVis !== "none" && <a className="LoadMoreButton" onClick={handleClick} style={{display: this.state.LoadMoreVis}}>Load More</a>}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…