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
Major change proposal: Let user decide what goes into state #103
Comments
I really like the idea of leaving it to the consumer to construct their state. It avoids some of the issues with mixins that set state (clashing names and discoverability mostly). In general it seems more correct and flexible also.
|
Could over be handled with something like this for source? Or am I missing the goal of over? |
I meant there to be separate methods like
Usually in |
This sounds pretty good. 👍 |
We're ready to go ahead with this. Things to be considered:
Overall the right course is to start from scratch and make examples work, from the simplest one to more complex ones. |
Let's do the work in this branch: https://github.com/gaearon/react-dnd/tree/dnd-core |
Superseded by #111, let's track progress there. |
Support AMD, CJS and browser global environments
Currently we have functions like
getDragState(type)
,getDropState(type)
,getDragLayerState()
. They can be used fromrender
but they're limiting in several ways:componentDidUpdate
or similar lifecycle hooks, you can't compare with previous values and thus react to changes.PureRenderMixin
, you can't opt out of reconciling when the state of mixin changes. For example, you can't make a drag layer that would only update in 10 pixel steps. If you were implementing it yourself, you could have putMath.round(currentOffset.x)
intostate.x
and usePureRenderMixin
to avoid extra changes, butgetDragLayerState()
is opaque and uses underlying component's state as it wishes.I wonder if we should change the contract so user defines methods that tell us what to keep in
state
. For example, drag panel that rounds values:Similarly, for drop targets (drag sources are the same):
If we can do this we might even not need
enter
andleave
that much. I'd like to eventually move away from them in favor of React'scomponentDidUpdate
. This would also allow us not to addenterCurrent
and friends because consumer can just usecomponentDidUpdate
for that.We'd still need
over
though. Not sure what can be done there.The text was updated successfully, but these errors were encountered: