Endless render when observed element is TippyJS child #515
Unanswered
ChrisLincoln
asked this question in
Q&A
Replies: 2 comments
-
I haven't used Tippy, but could you try using the Headless version? import React from 'react';
import Tippy from '@tippyjs/react/headless'; // different import path!
function App() {
const [inViewRef, inView, entry] = useInView({
threshold: 0,
})
return (<Tippy
render={attrs => (
<div ref={inViewRef} {...attrs}>
My tippy box
</div>
)}
>
<button>My button</button>
</Tippy>
)
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you for your patient. I just realized I didn't hit 'save' on that code sandbox. There is no telling what was in there for you. I did try the headless version, but the behavior was the same. What I am going to do to work around it is render an empty span right before and put the observed-ref on that element. All my stuff is inline, so I don't have to worry about layout issues. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When using the useInView hook, I'm getting endless render calls when the element I want to know is in view is inside a TippyJS wrapper. The referenced codebox is a mesh of the simple one found in the storybook where the observed element is the normally rendered content of Tippy. Sometimes TippyJS in a react functional component can be a bit like walking on eggshells, and I think this might be an example of one. I really like the DX with it, though. My apologies for the lack of clarity in the simple sandbox. I was trying lots of dumb stuff to see if I could figure out what makes this usage different than normal useInView usage.
https://codesandbox.io/s/useinview-forked-jnofg?file=/src/index.tsx
Beta Was this translation helpful? Give feedback.
All reactions