【发布时间】:2018-07-12 18:02:06
【问题描述】:
我已经找到了这个问题 How to use React DnD with styled component? 但在我的特殊情况下,它对我没有帮助,因为我的 dragSource 也是我的 dropTarget。
像这样:
class MyComponent extends Component {
...
render() {
const { connectDragSource, connectDropTarget, ... } = this.props;
return (
connectDragSource &&
connectDropTarget &&
connectDragSource(
connectDropTarget(
<MyStyledComponent>
<h1>foo</h1>
</MyStyledComponent>
)
)
);
}
}
所以问题是:如何使用 innerRef 来调用我的 connectDragSource AND 我的 connectDropTarget。
【问题讨论】:
标签: styled-components react-dnd