[ListItem] ListItem is not forwarding refs
See original GitHub issueDescribe the bug
The <ListItem />
component is not forwardings ref
s.
Expected Behavior
The <ListItem />
component is forwardings ref
s.
Steps to Reproduce
See the code: https://github.com/chakra-ui/chakra-ui/blob/develop/packages/layout/src/list.tsx#L97
The <ListItem />
is defined as:
export const ListItem = (props: PropsOf<typeof chakra.li>) => (
<chakra.li {...props} />
)
Suggested solution(s)
export const ListItem = React.forwardRef(function ListItem(
props: PropsOf<typeof chakra.li>,
ref: React.Ref<any>,
) {
return (
<chakra.li ref={ref} {...props} />
)
})
I think this would be it? But I might be missing something and there is a reason for this. For a workaround I used <Box as="li" />
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to use Forwarding Refs with react-router-dom
I already understand the concept of Forwarding Refs and react-router-dom. But in this implementation, I'm not sure how to use it correctly.
Read more >Forwarding Refs - React
Ref forwarding is a technique for automatically passing a ref through a component to one of its children. This is typically not necessary...
Read more >Composition - Material UI - MUI
You can use React.forwardRef and a designated prop in your class component to forward the ref to a DOM component. Doing so should...
Read more >Send email in a workflow - Microsoft Support
Sending an email when a list item was added in some versions of ... Note: If you do not see SharePoint 2013 Workflow...
Read more >Build strongly typed polymorphic components with React and ...
<List component="nav"> <ListItem button> <ListItemText ... if the ref is forwarded, or ComponentPropsWithoutRef when refs are not supported.
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 FreeTop 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
Top GitHub Comments
I managed to fix it before seeing this issue. Thanks for catching that @mkaradeniz.
naturally, I forgot it, but I’ll add it as soon as Sage is done with his
forwardRef
change.