-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
[Feature Request] allow to pass react fragments or insert react nodes between list items #49
Comments
@VityaSchel Please provide any code snippet you would like to use. |
I had the same issue, I have an UI where every swipable item has a title. I tried wrapping the item in a import { Children, ReactNode, cloneElement } from 'react'
export type SwipableListItemProxyProps = {
header?: ReactNode
footer?: ReactNode
children: ReactNode
} & Record<string, any>
export function SwipableListItemProxy({
children,
header,
footer,
...props
}: SwipableListItemProxyProps) {
return (
<>
{header}
{Children.map(children, (child, index) =>
cloneElement(child as any, {
...props,
})
)}
{footer}
</>
)
} Now I can use it like that: <SwipeableList type={ListType.IOS}>
<SwipableListItemProxy header={<div>My Header</div>}>
<SwipeableListItem>...</SwipeableListItem>
</SwipableListItemProxy>
</SwipeableList> It's far from perfect, I don't like the component name nor the props and there's no error management, but it's easily customizable to suit other needs. |
Hey, I was wondering if is there any workaround for this issue? I'm struggling to implement this library along with dnd-kit/sortable. |
Did you try with my solution? |
Hey @it-nalon. Yes I tried to use your code as a template but I couldn't make it work for my case. I have to mention that I'm still learning and it was the first time that I tried to extend a library by my own. |
Currently it's impossible to use react-swipeable-list with fragments because it breaks and actions does not work.
The text was updated successfully, but these errors were encountered: