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?
Finding files for which a command fails
(Soft question) does light intensity oscillate really fast since it is a wave?
Ideas for 3rd eye abilities
What happens when a metallic dragon and a chromatic dragon mate?
Is domain driven design an anti-SQL pattern?
Can a planet have a different gravitational pull depending on its location in orbit around its sun?
extract characters between two commas?
Information to fellow intern about hiring?
Why is the design of haulage companies so “special”?
I see my dog run
Are objects structures and/or vice versa?
Are white and non-white police officers equally likely to kill black suspects?
Doomsday-clock for my fantasy planet
Should the British be getting ready for a no-deal Brexit?
What is GPS' 19 year rollover and does it present a cybersecurity issue?
Can one use the reaction spell from the War Caster feat to cast Bigby's Hand?
What do the Banks children have against barley water?
Is there a familial term for apples and pears?
How can I add custom success page
Can I legally use front facing blue light in the UK?
Why doesn't a const reference extend the life of a temporary object passed via a function?
Map list to bin numbers
Is it wise to hold on to stock that has plummeted and then stabilized?
A poker game description that does not feel gimmicky
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?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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