react-sigma
react-sigma copied to clipboard
A complete example on how to update the graph after initialization
I tried to re-render the graph after it rendered on initialization, but it's not working. So I tried to extend the component as follow:
import React from "react";
import { Sigma } from "react-sigma";
export default class SigmaForceUpdate extends React.Component {
constructor(props) {
super(props)
this.state = {
loaded: false
}
this.previousGraph = "";
}
componentDidUpdate() {
if (this.props.graph && JSON.stringify(this.props.graph) !== this.previousGraph) {
this.props.sigma.refresh();
this.setState({ loaded: true })
}
}
render() {
debugger;
if (!this.state.loaded)
return null
return <Sigma>
<SigmaForceUpdate></SigmaForceUpdate>
</Sigma>
}
}
but getting an error:
Warning: unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering.
in SigmaForceUpdate (at TwitterInfoMap.js:421)
in div (created by Sigma)
Please help. Thanks
Were you able to solve it? I have the same issue.
Were you able to solve it? I have the same issue.
sorry no