react-dnd / react-dnd-html5-backend

HTML5 backend for React DnD [Legacy Repo]
MIT License
145 stars 97 forks source link

[Question] Use React primitives #22

Closed pspeter3 closed 8 years ago

pspeter3 commented 8 years ago

Reading through the code, it seems that connecting a drag source mutates the DOM nodes and registers handlers as opposed to using React's handlers attribute setting. Is it possible to use React's attribute and event system instead?

If not, is it possible to safely connect the DragSource lazily, during an onClick handler?

pspeter3 commented 8 years ago

It seems like onMouseDown would likely be more correct.

gaearon commented 8 years ago

Would using React event/attribute system be beneficial here? Why?

gaearon commented 8 years ago

I’ll close because I don’t have plans to change this but feel free to continue the discussion.

pspeter3 commented 8 years ago

I had erroneously believed that connecting a drag source and drop target was performance wise expensive since it was outside of the React render cycle. I do wonder if there would be value since it would mean there is only one system to reason about

gaearon commented 8 years ago

I don’t think it’s that expensive per se to be honest. If you check http://gaearon.github.io/react-dnd/examples-sortable-stress.html it works pretty fast despite having 1000 items. Currently backends have no dependency on React and can potentially be reused outside of it, and I’d like to keep them this way.