Skip to content
New issue

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

[question]: How can I combine useMeasure with useHoverDirty #2538

Open
mortalYoung opened this issue Jan 23, 2024 · 1 comment
Open

[question]: How can I combine useMeasure with useHoverDirty #2538

mortalYoung opened this issue Jan 23, 2024 · 1 comment

Comments

@mortalYoung
Copy link

mortalYoung commented Jan 23, 2024

I have to listen the container's rect changed, and get the hover state. I get this code:

const [ref, rect] = useMeasure();
const isHovering = useHoverDirty(ref); // No

How to get the ref by useMeasure and transit it into useHoverDirty?

@Piyushjaiswal19
Copy link

import useRef from 'react';
import useMeasure from 'react-use';
import useHoverDirty from 'react-use-gesture';

function YourComponent() {
const [ref, rect] = useMeasure();
const hoverRef = useRef(); //Here create a ref for UseHoverDirty

// Attach the ref to the DOM element obtained from useMeasure
hoverRef.current = ref.current;

// Now, you can use the hoverRef for the UseHoverDirty hook
const isHovering = useHoverDirty(hoverRef);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants