我在React中有一个带有引用的类组件,我想在其内部的功能组件中访问它。我尝试将ref作为道具传递,但随后它说它是未定义的。因此,我尝试使用this.refs
访问它,但它也是未定义的。
function GetOffset() {
const [offset, setOffset] = useState(0);
useEffect(() => {
function handleScroll() {
console.log(this.refs);
}, [offset]);
}
我想使用getBoundingClientRect()
检查元素的偏移量,但是首先我需要从该组件内部访问ref。
我读到使用类组件可以工作,但是我需要useEffect()
钩子。有提示吗?
答案 0 :(得分:1)
->where("today_date >= current_date - interval 6 day and today_date < current_date + interval 1 day")