8000 feat(hooks): useSortableList hook by Powerplex · Pull Request #2884 · leboncoin/spark-web · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@Powerplex
Copy link
Member

Description, Motivation and Context

  • new public hook: useSortableList. Allows users to make any list sortable.
  • added advanced example on how to combine the hook with FileUpload to reorder files.

Types of changes

  • ✨ New feature (non-breaking change which adds functionality)

Screenshots - Animations

Enregistrement.de.l.ecran.2025-11-24.a.15.58.19.mov


const [files, setFiles] = useState<File[]>(defaultFiles)

const { getItemProps } = useSortableList<File, HTMLLIElement>({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't it be inferred?

  const { getItemProps } = useSortableList({

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File could be ✅

The ref type can't be inferred, because here we pass the data to the hook, but it needs to return a ref for an Element and can't infer what type of element it will be (in most cases it will be an li, but it could be something else)

{ id: '10', name: 'Item 10' },
])

const { getItemProps } = useSortableList<SimpleItem, HTMLLIElement>({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@Powerplex Powerplex merged commit c3a46f4 into main Nov 24, 2025
11 checks passed
@Powerplex Powerplex deleted the demo-fileupload-sortable branch November 24, 2025 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0