すべての例で、ハードコードされたDropTargetタイプを見てきました。
DropTarget(DragDropTypes.Item, target, collect)(ShopContainer);
しかし、私がやりたいのは、親コンポーネントが型を渡して、他のDropTarget型にコンテナーを再利用できるようにすることです。
<ShopContainer dropTargetType={DragDropType.AnotherType} />
//and for my drop target to dynamically set the type
DropTarget(props.dropTargetType, target, collect)(ShopContainer);
私は現在、必要なタイプごとに1つずつ、複数のDropTargetコンテナーをエクスポートすることでこれを回避しようとしています。
実際、私はそれを理解しました。 ドコを5回読んで、最終的に次の意味を理解しました。
A string, an ES6 symbol, an array of either, or a function that returns either of those, given component's props.
NS
DropTarget((props) => {return props.dropTargetType;}, target, collect)(ShopContainer);
@mordrax私はそれを5回以上読みましたが、決してそれを取得しませんでした。 今私がやります。
@gaearonドキュメントやチュートリアルにこのような例があるはずです。 それを除けば、私はそれらが両方とも優れていると感じています。
@mordraxは私の日を救った
@ nsuthar0914 Elmに移動しました、
最も参考になるコメント
実際、私はそれを理解しました。 ドコを5回読んで、最終的に次の意味を理解しました。
A string, an ES6 symbol, an array of either, or a function that returns either of those, given component's props.
NS