Passing extra props to graph
anorman1967 opened this issue · comments
I'm trying to use the network to select nodes, and once a node is selected I want the event to execute a function in the parent component.
normally, I would pass some extra prop to the child component (network in this case) and then within the child I could run the parent function.
from parent:
<Graph graph={graph} options={options} events={events} myfunc={this.myfunc.bind(this)} />
And then in the event in the graph I could call the myfunc
this.props.myfunc(event)
Is there a way to do this? I'm probably just missing something, or a better way to do it in general -- I'm relatively new to react..
You have to attach it to one of the events already available. For example:
const events = {
selectNode: (e) => {
this.props.myfunc(e);
}
}
When you call the component, your event will be passed through with events
:
<Graph graph={graph}
options={options}
events={events} />