LifeCycle
์ด๋ค ์ปดํฌ๋ํธ์์๋ ์ธ ์ ์๋ค.
class Articles extends Component {
}
๋ฐ๋ก extends ๋ค์ ์ด Component ๋๋ฌธ์ ์ค์ง App ์ปดํฌ๋ํธ๊ฐ ์๋ ํ์์ปดํฌ๋ํธ์๋ ์ธ ์ ์๋ค.
Event
ํ์ด์ง๋ณ ์ด๋ฒคํธ๋ฅผ ์ ์ดํ๊ธฐ์ ์ ์ฉํ๋ค.
componentDidMount() {
window.addEventListener('scroll', debounce(this.handlelistLoadScroll));
}
componentWillUnmount() {
window.removeEventListener('scroll', debounce(this.handlelistLoadScroll));
}
์ด๋ ๊ฒ ์ฌ์ฉํ ์ ์๋๋ฐ ์ฌ๊ธฐ์ ๋ฌธ์ ๋
debounce(this.handlelistLoadScroll)
์ด ๋ถ๋ถ์ด๋ค. remove๊ฐ ๋์ง ์๋ ์ด์ ๋ debounce ์ํฅ์ผ๋ก ์ฐธ์กฐ๊ฐ ๋์ง ์๋๋ค
๊ทธ๋ ๊ธฐ ๋๋ฌธ์ ํ๋กํผํฐ์ ์ ์ฅ์ ํ ํ ์ฐธ์กฐ๋ฅผ ํด์ผํ๋ค!
Last updated
Was this helpful?