B
B
BuG1K2018-06-10 10:34:34
React
BuG1K, 2018-06-10 10:34:34

How to request componentDidMount() on page scroll?

componentDidMount() {
  this.props.fetchData(url);
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Aleksandrovich, 2018-06-10
@RomReed

componentDidMount() {
   
      document.documentElement.addEventListener('scroll', this.handleScroll);
    
  }

  componentWillUnmount() {
    document.documentElement.removeEventListener('scroll', this.handleScroll);
  }

 
  handleScroll() {
   this.props.fetchData(url);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question