Skip to content
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

Create component to handle transitions in lists #302

Open
leroykorterink opened this issue Jan 19, 2024 · 0 comments
Open

Create component to handle transitions in lists #302

leroykorterink opened this issue Jan 19, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@leroykorterink
Copy link
Collaborator

It'd be nice to support transitions in lists

<TransitionPresenceList>
  {myArray.map((value) => (
    <MyComponent key={value.key} />
  ))}
</TransitionPresenceList>

Implementation could be similar to this:

type TransitionPresenceListProps = {
  children: ReadonlyArray<ReactElement>
};

function TransitionPresenceList({ children }: TransitionPresenceListProps): ReactElement {
  return Children.map(children, (child, index) => (
    // The TransitionPresence instance is re-used when the key doesn't change
    <TransitionPresence key={index}>
      {child}
    </TransitionPresence>
  ));
}
@leroykorterink leroykorterink added enhancement New feature or request help wanted Extra attention is needed labels Jan 19, 2024
@leroykorterink leroykorterink self-assigned this Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant