`Slot` not working with `React.useImperativeHandle`
See original GitHub issueBug report
Current Behavior
I’m creating a custom tooltip following the docs here. Everything works well with DOM elements but when I’m using a custom component with React.useImperativeHandle
it throws with
Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.
I narrowed it down to the useImperativeHandle
call. If I remove it it works fine, but I need it to forward the .focus()
function.
Expected behavior
It should work and not throw.
Reproducible example
Your environment
Software | Name(s) | Version |
---|---|---|
Radix Package(s) | @radix-ui/react-polymorphic | v0.0.11 |
@radix-ui/react-slot | v0.0.10 | |
@radix-ui/react-tooltip | v0.0.18 | |
React | n/a | v17.0.1 |
Browser | Chrome | v91.0.4472.101 |
Node | n/a | v12.20.0 |
yarn | n/a | v1.22.10 |
Operating System | macOS | v10.15.7 |
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
declare type with React.useImperativeHandle() - Stack Overflow
I try to use a child method in a parent component using ref and React.useImperativeHandle() . It works well. but I am not...
Read more >The Power of React Hooks - JSManifest
Our slotify function is invoked when the user presses the Start Quotifying button to slotify their blog post. The intention is to pop...
Read more >Type '{}' is not assignable to type 'ReactNode'. #35986 - GitHub
The issue is that after upgrading to the last nextjs version, I am getting the error Type 'Component<{}, any, any>' is not assignable...
Read more >The Power of React Hooks - Better Programming
This slot component takes in a quote from the user. This won't be visible to the user right away because we're going to...
Read more >What is hidden behind React's refs ? | No Code, No Bug
Well, not quite so. We are missing one problem: what if you want the ref you attached to a React component to go...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Makes sense. Feel free to close the issue if you like 😃
Potentially, I haven’t really looked into it yet.
useImperativeHandle
is also so rare that it is probably safe to ignore for now. Especially given the fact thatSlot
is to be used around an element, and by usinguseImperativeHandle
you’d lose the actual DOM ref.