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

Fix for images #43

Open
a-drewsky opened this issue Jun 10, 2021 · 4 comments
Open

Fix for images #43

a-drewsky opened this issue Jun 10, 2021 · 4 comments

Comments

@a-drewsky
Copy link

I don't know if this has been addressed but it took me an hour to figure out. If you want to use images in the grid items you have to add onDragStart={(e) => {e.preventDefault()}} to the img element.

@fomson
Copy link

fomson commented Jul 9, 2021

This was a bit laggy at first, but then started working beautifully, thank you!

@craigcosmo
Copy link

@a-drewsky do you have problem with the order after dragging?

function onChange(sourceId, sourceIndex, targetIndex, targetId) {
		const nextState = swap(items, sourceIndex, targetIndex)
		setItems(nextState)
	        console.log('items', items)
	}

in this code I tried to see the state in console after dragging. The console will show the previous state now the after dragging. Any idea why ?

@mleister97
Copy link

Thanks!

@BigBahss
Copy link

@a-drewsky do you have problem with the order after dragging?

function onChange(sourceId, sourceIndex, targetIndex, targetId) {
		const nextState = swap(items, sourceIndex, targetIndex)
		setItems(nextState)
	        console.log('items', items)
	}

in this code I tried to see the state in console after dragging. The console will show the previous state now the after dragging. Any idea why ?

(I realize this comment is a bit old, but figured I'd answer anyways.)
This is simply how React works. After calling your setter function from the useState hook, the new value of your state will not be reflected in the state variable until the next iteration of the event loop. This makes it so that each iteration of the loop has a consistent snapshot of the state of your application.

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

5 participants