We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, just found another issue:
function Demo() { const [visible, setVisible] = useState(false) const buttonRef = useRef(null) const onClick = () => { console.log('button clicked!') // not working... } useEventListener('click', onClick, buttonRef) useTimeoutFn(() => { setVisible(true) }, 1000) return visible ? <button ref={buttonRef}>Click me</button> : null }
If the button is visible at first, then the event can be bound successfully.
All hooks using useEventListener might be affected in this situation, at least useScroll is not working. Perhaps we should test them all.
useEventListener
useScroll
Sorry to bother ;-) 🥰
The text was updated successfully, but these errors were encountered:
This is a classic issue in React, as initially, the element bound with the ref does not exist.
May be you can try it to
function Demo() { const [visible, setVisible] = useState(false) const [buttonRef, setButtonRef] = useState(null) const onClick = () => { console.log('button clicked!') // not working... } useEventListener('click', onClick, buttonRef) useTimeoutFn(() => { setVisible(true) }, 1000) return visible ? <button ref={setButtonRef}>Click me</button> : null }
Sorry, something went wrong.
This is a classic issue in React, as initially, the element bound with the ref does not exist. May be you can try it to function Demo() { const [visible, setVisible] = useState(false) const [buttonRef, setButtonRef] = useState(null) const onClick = () => { console.log('button clicked!') // not working... } useEventListener('click', onClick, buttonRef) useTimeoutFn(() => { setVisible(true) }, 1000) return visible ? <button ref={setButtonRef}>Click me</button> : null }
Thanks, it works!
No branches or pull requests
Reproduction
Hi, just found another issue:
If the button is visible at first, then the event can be bound successfully.
All hooks using
useEventListener
might be affected in this situation, at leastuseScroll
is not working. Perhaps we should test them all.Sorry to bother ;-) 🥰
The text was updated successfully, but these errors were encountered: