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
问题:使用 useOnScreenCallback 这个 hook 返回的 ref,赋值给 DOM 元素后,ref.current 不能获取到 DOM。但在使用中会有需要获取这个 DOM 进行操作的情景(比如 add/remove classList 来显示动画);
useOnScreenCallback
期望:希望赋值完 ref={ref} 后,ref.current 可以获取 DOM 结构,这样可以在 callback 里直接进行后续操作。
参考 demo:https://codesandbox.io/s/heuristic-haslett-s1qs8?fontsize=14&hidenavigation=1&theme=dark
The text was updated successfully, but these errors were encountered:
忘记有 entry.target 了
Sorry, something went wrong.
顺便提一下,类似其它需要这种功能的场景,也可以这样:
const elementRef = useRef(null); const registerOnScreen = useOnScreenCallback(...); const ref = useMergedRef([elementRef, registerOnScreen]); <div ref={ref} />
参考:https://ecomfe.github.io/react-hooks/#/hook/merged-ref/use-merged-ref
No branches or pull requests
问题:使用
useOnScreenCallback
这个 hook 返回的 ref,赋值给 DOM 元素后,ref.current 不能获取到 DOM。但在使用中会有需要获取这个 DOM 进行操作的情景(比如 add/remove classList 来显示动画);期望:希望赋值完 ref={ref} 后,ref.current 可以获取 DOM 结构,这样可以在 callback 里直接进行后续操作。
参考 demo:https://codesandbox.io/s/heuristic-haslett-s1qs8?fontsize=14&hidenavigation=1&theme=dark
The text was updated successfully, but these errors were encountered: