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

Preview is not working for the first drag #3606

Open
psyycker opened this issue Nov 17, 2023 · 2 comments
Open

Preview is not working for the first drag #3606

psyycker opened this issue Nov 17, 2023 · 2 comments

Comments

@psyycker
Copy link

Hi!

I have the following piece of code:
Screenshot 2023-11-17 at 16 44 27
(I put a screenshot as you can see the types as well)
It is a simple react component with a header (which is the grabbing source) and the whole container being set as the preview.

However, when trying to do the first grab, the preview won't work. It'll only work the second time I grab:
https://github.com/react-dnd/react-dnd/assets/9397742/4ea64b0d-d189-4cff-9d04-cc522d7aa7a4

The component is using useGrab in the most simple way like this:
Screenshot 2023-11-17 at 16 48 45
I followed the tutorial on the website and cannot see anything I missed.

Desktop (please complete the following information):

  • OS: MacOS Latest version
  • Chrome
  • Version 119
@johndalloxx
Copy link

The way you do it here you are both rendering the div and the component.

The final return statement should look like this:

return isDragging ? (<div ref={preview} />) : (<Component ref={drag} />)

@psyycker
Copy link
Author

psyycker commented Dec 6, 2023

@johndalloxx it's impossible to return both the div and the component.
When doing the first return, the execution stops.

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

2 participants