react-dnd DragSource that has child DragSourceLoop inside React JSXReact js onClick can't pass value to methodWhat do these three dots in React do?Programmatically navigate using react routerWhen using React-DnD: How can I / should I even try to the access the state of a wrapped child component?React D3 Tree Chart Improper RerenderingWhat is the difference between React Native and React?assert react component child(ren) existence/absence using jestjsHow do you move a dragsource with React-DND?React - How do I give each child component a unique ref?
Is there a conventional notation or name for the slip angle?
Is it possible to have a strip of cold climate in the middle of a planet?
How do I implement a file system driver driver in Linux?
Some numbers are more equivalent than others
Indicating multiple different modes of speech (fantasy language or telepathy)
Transformation of random variables and joint distributions
Can someone explain how this makes sense electrically?
Did US corporations pay demonstrators in the German demonstrations against article 13?
Why did the EU agree to delay the Brexit deadline?
A Permanent Norse Presence in America
How will losing mobility of one hand affect my career as a programmer?
Greatest common substring
Is camera lens focus an exact point or a range?
Would it be legal for a US State to ban exports of a natural resource?
How do ground effect vehicles perform turns?
How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?
Folder comparison
What is the grammatical term for “‑ed” words like these?
Why has "pence" been used in this sentence, not "pences"?
Proof of Lemma: Every nonzero integer can be written as a product of primes
Is a model fitted to data or is data fitted to a model?
Can a significant change in incentives void an employment contract?
Could solar power be utilized and substitute coal in the 19th century?
Has Darkwing Duck ever met Scrooge McDuck?
react-dnd DragSource that has child DragSource
Loop inside React JSXReact js onClick can't pass value to methodWhat do these three dots in React do?Programmatically navigate using react routerWhen using React-DnD: How can I / should I even try to the access the state of a wrapped child component?React D3 Tree Chart Improper RerenderingWhat is the difference between React Native and React?assert react component child(ren) existence/absence using jestjsHow do you move a dragsource with React-DND?React - How do I give each child component a unique ref?
I have a tree structure with a root "Tree" component that has a list of root "TreeNodes", then TreeNodes can have an arbitrary number of children.
So inside of the TreeNode render method I have
childrenHTML = this.state.children.map((child) =>
return (<TreeNode nodeClick =this.props.nodeClick parentNode=this
key=child.childId node=child level=this.state.level+1 />);
);
and
const isDragging, connectDragSource, connectDragPreview = this.props;
Then the final return for the render method looks like
return connectDragSource(
<div>
<div style=nodeStyle>
connectDragPreview(
<div className = "nodeContainer" + ' ' + this.state.nodeHover onMouseLeave=this.nodeUnHover onMouseOver=this.nodeHover onClick=()=>this.props.nodeClick(this)>
<img alt = this.state.titleIcon className = "titleIcon" src = Connections.getImageURLByName(this.state.titleIcon) />
<p className="nodeLabel"> this.state.nodeName</p>
nodeLabelsHTML
<DescriptiveIcons descriptiveIcons=this.state.icons />
</div>
)
</div>
childrenHTML
</div>
);
I am exporting:
export default DragSource(DragTypes.STRUCTURE, treeNodeSource, collect)(TreeNode);
Then in the parent Tree file I am exporting
export default DragDropContext(HTML5Backend)(Tree)
and rendering the rootnodes like
rootNodesHTML = rootNodes.map((node) =>
return <TreeNode nodeClick=this.props.nodeClick key=node.childId node=node level=0/>
);
...
return (
<div className="treeContainer">
<div className="wrapContainer">
rootNodesHTML
</div>
</div>
);
This works great but only for the rootnodes, when I try to render the children (the childrenHTML variable is only populated after the parent is clicked on) I get the following error:TypeError: connectDragPreview is not a function
Leading me to believe that those react-dnd props that come from the "collect" function is not being passed to the rootnodes but not the children. It seems like it should to me because the same code should be executed for the parents as for the children as its the same class... really stuck here.
I am relatively new to react, and new to ideas like HOCs so all tips or suggestions are appreciated. Thank you!
javascript reactjs react-dnd
add a comment |
I have a tree structure with a root "Tree" component that has a list of root "TreeNodes", then TreeNodes can have an arbitrary number of children.
So inside of the TreeNode render method I have
childrenHTML = this.state.children.map((child) =>
return (<TreeNode nodeClick =this.props.nodeClick parentNode=this
key=child.childId node=child level=this.state.level+1 />);
);
and
const isDragging, connectDragSource, connectDragPreview = this.props;
Then the final return for the render method looks like
return connectDragSource(
<div>
<div style=nodeStyle>
connectDragPreview(
<div className = "nodeContainer" + ' ' + this.state.nodeHover onMouseLeave=this.nodeUnHover onMouseOver=this.nodeHover onClick=()=>this.props.nodeClick(this)>
<img alt = this.state.titleIcon className = "titleIcon" src = Connections.getImageURLByName(this.state.titleIcon) />
<p className="nodeLabel"> this.state.nodeName</p>
nodeLabelsHTML
<DescriptiveIcons descriptiveIcons=this.state.icons />
</div>
)
</div>
childrenHTML
</div>
);
I am exporting:
export default DragSource(DragTypes.STRUCTURE, treeNodeSource, collect)(TreeNode);
Then in the parent Tree file I am exporting
export default DragDropContext(HTML5Backend)(Tree)
and rendering the rootnodes like
rootNodesHTML = rootNodes.map((node) =>
return <TreeNode nodeClick=this.props.nodeClick key=node.childId node=node level=0/>
);
...
return (
<div className="treeContainer">
<div className="wrapContainer">
rootNodesHTML
</div>
</div>
);
This works great but only for the rootnodes, when I try to render the children (the childrenHTML variable is only populated after the parent is clicked on) I get the following error:TypeError: connectDragPreview is not a function
Leading me to believe that those react-dnd props that come from the "collect" function is not being passed to the rootnodes but not the children. It seems like it should to me because the same code should be executed for the parents as for the children as its the same class... really stuck here.
I am relatively new to react, and new to ideas like HOCs so all tips or suggestions are appreciated. Thank you!
javascript reactjs react-dnd
add a comment |
I have a tree structure with a root "Tree" component that has a list of root "TreeNodes", then TreeNodes can have an arbitrary number of children.
So inside of the TreeNode render method I have
childrenHTML = this.state.children.map((child) =>
return (<TreeNode nodeClick =this.props.nodeClick parentNode=this
key=child.childId node=child level=this.state.level+1 />);
);
and
const isDragging, connectDragSource, connectDragPreview = this.props;
Then the final return for the render method looks like
return connectDragSource(
<div>
<div style=nodeStyle>
connectDragPreview(
<div className = "nodeContainer" + ' ' + this.state.nodeHover onMouseLeave=this.nodeUnHover onMouseOver=this.nodeHover onClick=()=>this.props.nodeClick(this)>
<img alt = this.state.titleIcon className = "titleIcon" src = Connections.getImageURLByName(this.state.titleIcon) />
<p className="nodeLabel"> this.state.nodeName</p>
nodeLabelsHTML
<DescriptiveIcons descriptiveIcons=this.state.icons />
</div>
)
</div>
childrenHTML
</div>
);
I am exporting:
export default DragSource(DragTypes.STRUCTURE, treeNodeSource, collect)(TreeNode);
Then in the parent Tree file I am exporting
export default DragDropContext(HTML5Backend)(Tree)
and rendering the rootnodes like
rootNodesHTML = rootNodes.map((node) =>
return <TreeNode nodeClick=this.props.nodeClick key=node.childId node=node level=0/>
);
...
return (
<div className="treeContainer">
<div className="wrapContainer">
rootNodesHTML
</div>
</div>
);
This works great but only for the rootnodes, when I try to render the children (the childrenHTML variable is only populated after the parent is clicked on) I get the following error:TypeError: connectDragPreview is not a function
Leading me to believe that those react-dnd props that come from the "collect" function is not being passed to the rootnodes but not the children. It seems like it should to me because the same code should be executed for the parents as for the children as its the same class... really stuck here.
I am relatively new to react, and new to ideas like HOCs so all tips or suggestions are appreciated. Thank you!
javascript reactjs react-dnd
I have a tree structure with a root "Tree" component that has a list of root "TreeNodes", then TreeNodes can have an arbitrary number of children.
So inside of the TreeNode render method I have
childrenHTML = this.state.children.map((child) =>
return (<TreeNode nodeClick =this.props.nodeClick parentNode=this
key=child.childId node=child level=this.state.level+1 />);
);
and
const isDragging, connectDragSource, connectDragPreview = this.props;
Then the final return for the render method looks like
return connectDragSource(
<div>
<div style=nodeStyle>
connectDragPreview(
<div className = "nodeContainer" + ' ' + this.state.nodeHover onMouseLeave=this.nodeUnHover onMouseOver=this.nodeHover onClick=()=>this.props.nodeClick(this)>
<img alt = this.state.titleIcon className = "titleIcon" src = Connections.getImageURLByName(this.state.titleIcon) />
<p className="nodeLabel"> this.state.nodeName</p>
nodeLabelsHTML
<DescriptiveIcons descriptiveIcons=this.state.icons />
</div>
)
</div>
childrenHTML
</div>
);
I am exporting:
export default DragSource(DragTypes.STRUCTURE, treeNodeSource, collect)(TreeNode);
Then in the parent Tree file I am exporting
export default DragDropContext(HTML5Backend)(Tree)
and rendering the rootnodes like
rootNodesHTML = rootNodes.map((node) =>
return <TreeNode nodeClick=this.props.nodeClick key=node.childId node=node level=0/>
);
...
return (
<div className="treeContainer">
<div className="wrapContainer">
rootNodesHTML
</div>
</div>
);
This works great but only for the rootnodes, when I try to render the children (the childrenHTML variable is only populated after the parent is clicked on) I get the following error:TypeError: connectDragPreview is not a function
Leading me to believe that those react-dnd props that come from the "collect" function is not being passed to the rootnodes but not the children. It seems like it should to me because the same code should be executed for the parents as for the children as its the same class... really stuck here.
I am relatively new to react, and new to ideas like HOCs so all tips or suggestions are appreciated. Thank you!
javascript reactjs react-dnd
javascript reactjs react-dnd
asked Mar 8 at 7:09
Dylan KiddDylan Kidd
69212
69212
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I was able to get this working. Check out the example posted at the end of the thread in
https://github.com/react-dnd/react-dnd/issues/332.
Ultimately the solution was to wrap the TreeNode in a "DragContainer" with a very simple render method
render()
const ...props = this.props;
return <TreeNode ...props/>
Then in the TreeNode render method, when rendering the child nodes render a DragContainer instead, passing in all the usual props.
childrenHTML = this.state.children.map((child) =>
return <DragNodeContainer modalFunctions = this.props.modalFunctions nodeClick =this.props.nodeClick parentNode=this key=child.childId node=child level=this.state.level+1 />;
);
I am still unsure as to the technical reason for this, however, the fix seems to work for other people and it works for me!
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058359%2freact-dnd-dragsource-that-has-child-dragsource%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I was able to get this working. Check out the example posted at the end of the thread in
https://github.com/react-dnd/react-dnd/issues/332.
Ultimately the solution was to wrap the TreeNode in a "DragContainer" with a very simple render method
render()
const ...props = this.props;
return <TreeNode ...props/>
Then in the TreeNode render method, when rendering the child nodes render a DragContainer instead, passing in all the usual props.
childrenHTML = this.state.children.map((child) =>
return <DragNodeContainer modalFunctions = this.props.modalFunctions nodeClick =this.props.nodeClick parentNode=this key=child.childId node=child level=this.state.level+1 />;
);
I am still unsure as to the technical reason for this, however, the fix seems to work for other people and it works for me!
add a comment |
I was able to get this working. Check out the example posted at the end of the thread in
https://github.com/react-dnd/react-dnd/issues/332.
Ultimately the solution was to wrap the TreeNode in a "DragContainer" with a very simple render method
render()
const ...props = this.props;
return <TreeNode ...props/>
Then in the TreeNode render method, when rendering the child nodes render a DragContainer instead, passing in all the usual props.
childrenHTML = this.state.children.map((child) =>
return <DragNodeContainer modalFunctions = this.props.modalFunctions nodeClick =this.props.nodeClick parentNode=this key=child.childId node=child level=this.state.level+1 />;
);
I am still unsure as to the technical reason for this, however, the fix seems to work for other people and it works for me!
add a comment |
I was able to get this working. Check out the example posted at the end of the thread in
https://github.com/react-dnd/react-dnd/issues/332.
Ultimately the solution was to wrap the TreeNode in a "DragContainer" with a very simple render method
render()
const ...props = this.props;
return <TreeNode ...props/>
Then in the TreeNode render method, when rendering the child nodes render a DragContainer instead, passing in all the usual props.
childrenHTML = this.state.children.map((child) =>
return <DragNodeContainer modalFunctions = this.props.modalFunctions nodeClick =this.props.nodeClick parentNode=this key=child.childId node=child level=this.state.level+1 />;
);
I am still unsure as to the technical reason for this, however, the fix seems to work for other people and it works for me!
I was able to get this working. Check out the example posted at the end of the thread in
https://github.com/react-dnd/react-dnd/issues/332.
Ultimately the solution was to wrap the TreeNode in a "DragContainer" with a very simple render method
render()
const ...props = this.props;
return <TreeNode ...props/>
Then in the TreeNode render method, when rendering the child nodes render a DragContainer instead, passing in all the usual props.
childrenHTML = this.state.children.map((child) =>
return <DragNodeContainer modalFunctions = this.props.modalFunctions nodeClick =this.props.nodeClick parentNode=this key=child.childId node=child level=this.state.level+1 />;
);
I am still unsure as to the technical reason for this, however, the fix seems to work for other people and it works for me!
answered Mar 14 at 5:44
Dylan KiddDylan Kidd
69212
69212
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55058359%2freact-dnd-dragsource-that-has-child-dragsource%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown