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

Types for parentRef #26

Open
mire-toctoc opened this issue Mar 5, 2024 · 2 comments
Open

Types for parentRef #26

mire-toctoc opened this issue Mar 5, 2024 · 2 comments
Assignees

Comments

@mire-toctoc
Copy link

mire-toctoc commented Mar 5, 2024

Does the drag and drop functionality just accepts the use of <ul> and <li> tags?

I'm currently having an issue related to the parent definition, where the error Type 'MutableRefObject<HTMLUListElement>' is missing the following properties from type 'HTMLElement': accessKey, accessKeyLabel, autocapitalize, dir, and 290 more. is present. I've tried different definition types for my parentRef, but is not working. Before this definition, I was trying to use a <div>, but it has the same problem.

Please, give us more information about expected types in both

useDragAndDrop

and

dragAndDrop

hooks, so users can avoid having this kind of issues

My implementation:

const parentRef = React.useRef() as React.MutableRefObject<HTMLUListElement>;
	const [imagesList, setImagesList] = useState(images)
		dragAndDrop({
			parent: parentRef,
			state: [imagesList, setImagesList]
			})

@justin-schroeder
Copy link
Member

no

@mire-toctoc mire-toctoc changed the title does de drag and drop functionality just accepts the use of <ul> and <li> tags? Types for parentRef Mar 5, 2024
@malshoff
Copy link

malshoff commented Apr 26, 2024

you can use parent: parentRef, but then you're still going to have issues afterwards with the line below it:

Object literal may only specify known properties, and 'state' does not exist in type 'DragAndDrop<unknown>'

Personally, I've never gotten this to work properly with React unless I use nothing but the demo ul/li implementation with the useDragAndDrop hook. The only documentation otherwise is a 3 line snippet that doesn't even show useful usage, so I'd recommend @hello-pangea/dnd library instead for now.

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

No branches or pull requests

4 participants