New to react hook world, trying to learn by coding, i'm not sure about this componentDidUpdate
to where put it inside useEffect
any suggestions ?
this is my code:
componentDidMount() {
if (!this.props.realGraph) {
this.loadGraph();
}
this.refs.graphDiv.addEventListener("click", this.onClickGraphDiv, true);
}
discardGraph() {
this.props.clearGraphData();
this.loadGraph();
}
componentDidUpdate() {
this._zoomConfig();
}
_zoomConfig = () => {
const z = d3Select(`#graph-id-graph-wrapper`)
.call(d3Zoom())
.on("dblclick.zoom", null)
.on("mousedown.zoom", null)
};
realGrpah
comes from mapStateToProps
this is what i have done converting it to hooks,
useEffect(() => {
if (!props.realGraph) {
loadGraph();
}
refs.graphDiv.addEventListener("click", onClickGraphDiv, true);
_zoomConfig();
}, []);
discardGraph() {
props.dispatch(clearGraphData())
loadGraph();
}
_zoomConfig = () => {
const z = d3Select(`#graph-id-graph-wrapper`)
.call(d3Zoom())
.on("dblclick.zoom", null)
.on("mousedown.zoom", null)
};