<AllPosts ref={this.allPostsRef} allArticles={articles} reference={this.allPostsRef}/>
在Allpost.js
componentDidMount = () =>{
console.log("allposts component mounted!")
window.addEventListener("scroll", ()=>{console.log(window.scrollY)
console.log(this.props.reference.current.scrollTop)
})
}
为什么“ this.props.reference.current.scrollTop ”未定义?