question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can a single component be also a DragSource as well as DropTarget

See original GitHub issue

I believe a single component can be a DragSource as well as a DropTarget. I am doing a sortable <Layer> component sort of like your <Card> example. My question is how do I do both without using ES7?

In your <Card> example, you have

@DropTarget(ItemTypes.CARD, cardTarget, connect => ({
  connectDropTarget: connect.dropTarget(),
}))
@DragSource(ItemTypes.CARD, cardSource, (connect, monitor) => ({
  connectDragSource: connect.dragSource(),
  isDragging: monitor.isDragging()
}))
export default class Card {
}

But I want to only use ES6, so how do I combine both DragSource and DropTarget in here:

class Layer extends Component {
}

// Where to put the DropTarget??
export default DragSource('layer', layerSource, collect)(Layer);

Is it I have to use _.flow() from lodash?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:7
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
gaearoncommented, Aug 3, 2015

Good point. I’d say accessing instance is usually an anti-pattern. Why do you need it?

Anyway, you can access the “original” component by component.getDecoratedComponentInstance().

2reactions
gaearoncommented, Aug 2, 2015
Read more comments on GitHub >

github_iconTop Results From Across the Web

React DnD - GitHub Pages
How do I register a drag source or a drop target when the type depends on ... How do I combine several drag...
Read more >
Drag and Drop in React. Using react-dnd | by Sean LaFlam
A drag source is the draggable component. It's job is to carry the relevant info needed to perform some action to the drop...
Read more >
Implementing Drag and Drop - SurviveJS
In this chapter, we will integrate drag and drop functionality to it as ... import {compose} from 'redux'; import {DragSource, DropTarget} from 'react-dnd';....
Read more >
How to get setup with React DnD - codeburst
In this way you can add multiple components with DragSources to your ... our DragSource Spec, we could use also use drop() in...
Read more >
Drag and Drop Subsystem for the Java 2 Platform Standard ...
Component additions for DropTarget (de)registration; 2.4.2 The DropTarget ... A DragSource shall only permit a single drag and drop operation to be current...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found