Answer the question
In order to leave comments, you need to log in
How to wrap a component?
Hello, I made a clone of Trello on React and dnd on pure JS. I want to port dnd from JS to React, because when I drag an element into a list, it gets added to the list's children list in the DOM, but not added to the list's state, and there are a number of problems. Also I can't access list methods and its state from dnd. I have been learning React for a relatively short time, so I may not know some things. If I'm saying something wrong, please correct me. I think I need to make a board wrapper. Like this:
<DragManager>
<Board />
<DragManager />
Answer the question
In order to leave comments, you need to log in
Are you trying to use the methods of the wrapped component from the wrapper?) This won't work.
I think you should move the necessary methods to the parent component. Conditionally:
class Example extends React.Component {
state: {
}
needMethod1{
};
needMethod2{
}
render() {
return (
<DragManager needMethod1={this.needMethod1} needMethod2={this.needMethod2} >
<Board needMethod1={this.needMethod1} needMethod2={this.needMethod2} />
<DragManager />
)
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question