question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow possibility to use different reference on useFloating

See original GitHub issue

On usePopper we have an option to pass referenceElement and popperElement but in useFloating we don’t have that option.

The useFloating is responsible to return the refs but in some cases is not possible to set the returned ref to an element, because that referenceElement is passed as a prop (anchor is outside of my component), but looking to the docs I saw that useFloating use computePosition that receive this two references as an argument.

My solution is to use computePosition instead of useFloating but I will lose all functionalities provided by useFloating

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

3reactions
atomikscommented, Jan 13, 2022

So you’d do this:

function Component({anchorRef}) {
  const {reference} = useFloating();

  useLayoutEffect(() => {
    reference(anchorRef.current);
  }, [anchorRef]);
}

Just need to make sure when anchorRef.current gets updated that the position can also be updated

0reactions
mauroreisvieiracommented, Jan 13, 2022

Perfect, thanks @atomiks

Read more comments on GitHub >

github_iconTop Results From Across the Web

React - Floating UI
If you want anchor positioning to be relative to a different reference element than the one that receives events, this is possible. You...
Read more >
One reference, multiple floating components? · Issue #1821
We want a button with these behaviors: on hover, displays its title in a tooltip; on click, opens an action menu.
Read more >
floating-ui react-dom-interactions how to set floating element ...
I want to set the floating element width same as reference element. I have tried to follow this approach from documentation but didn't...
Read more >
How to use Floating ui with react | by Kyosuke Ito | Dev Genius
This toolkit is to create floating elements but not an animation library with floating elements. In other words, you can add your animation...
Read more >
PackageReference in project files - NuGet - Microsoft Learn
With PackageReference, you can also use MSBuild conditions to choose package references per target framework, or other groupings.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found