Skip to content

Fixed the children prop for DragOverlay#93

Merged
martinpengellyphillips merged 1 commit intothisbeyond:mainfrom
pardeshirzadeh:drag-overlay-children
Nov 17, 2023
Merged

Fixed the children prop for DragOverlay#93
martinpengellyphillips merged 1 commit intothisbeyond:mainfrom
pardeshirzadeh:drag-overlay-children

Conversation

@pardeshirzadeh
Copy link
Copy Markdown
Contributor

@pardeshirzadeh pardeshirzadeh commented May 15, 2023

DragOverlay is currently defined as ParentComponent<DragOverlayProps>, but it doesn't work in the following scenario in a .tsx file:

<DragOverlay>
  {(draggable) => <div>Drag overlay for {draggable?.id}</div>}
</DragOverlay>

It will throw the following error

Type '(draggable: Draggable$1 | null) => Element' is not assignable to type '((number | boolean | Node | ArrayElement | (string & {}) | ((activeDraggable: Draggable$1 | null) => Element)) & (number | boolean | Node | ArrayElement | (string & {}))) | null | undefined'.
  Type '(draggable: Draggable$1 | null) => Element' is not assignable to type '((activeDraggable: Draggable$1 | null) => Element) & number'.
    Type '(draggable: Draggable$1 | null) => Element' is not assignable to type 'number'.

The reason for that is because ParentComponent overrides children, so the definition in DragOverlayProps is ignored.

@martinpengellyphillips
Copy link
Copy Markdown
Contributor

Hmm, I don't understand. What does "not work" mean here?

@pardeshirzadeh
Copy link
Copy Markdown
Contributor Author

I updated the first comment with more details. Hope it's more clear now

@Adevien
Copy link
Copy Markdown

Adevien commented Nov 15, 2023

This is still a current issue on latest version. Any updates?

@martinpengellyphillips
Copy link
Copy Markdown
Contributor

Ah yes, I was just looking at this. I think we should use Component here still to maintain return type etc.

@martinpengellyphillips martinpengellyphillips merged commit 0d0140a into thisbeyond:main Nov 17, 2023
@malekim
Copy link
Copy Markdown

malekim commented Nov 17, 2023

Unfortunately, it didn't solve the issue.

TS2322: Type '(draggable: Draggable$1 | null) => Element' is not assignable to type '((number | boolean | Node | ArrayElement | (string & {}) | ((activeDraggable: Draggable$1 | null) => Element)) & (number | boolean | Node | ArrayElement | (string & {}))) | null | undefined'.   Type '(draggable: Draggable$1 | null) => Element' is not assignable to type '((activeDraggable: Draggable$1 | null) => Element) & number'.     Type '(draggable: Draggable$1 | null) => Element' is not assignable to type 'number'.`

@Adevien
Copy link
Copy Markdown

Adevien commented Nov 19, 2023

took latest commit, it did solved the issue as far as I can tell :)

@martinpengellyphillips
Copy link
Copy Markdown
Contributor

Thanks @Adevien - @malekim I wonder why not working for you 🤔

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.

5 participants