Skip to content

Create component to handle transitions in lists #302

@leroykorterink

Description

@leroykorterink

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>
  ));
}

Metadata

Metadata

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions