사용하기 detectScroll = () => { this.setState({ scrollY: window.scrollY, }); }; componentDidMount() { window.addEventListener('scroll', this.detectScroll); } componentWillUnmount() { window.removeEventListener('scroll', this.detectScroll); }
사용하기
detectScroll = () => { this.setState({ scrollY: window.scrollY, }); }; componentDidMount() { window.addEventListener('scroll', this.detectScroll); } componentWillUnmount() { window.removeEventListener('scroll', this.detectScroll); }