react-sigma icon indicating copy to clipboard operation
react-sigma copied to clipboard

A complete example on how to update the graph after initialization

Open huntertran opened this issue 5 years ago • 2 comments

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

huntertran avatar May 19 '20 14:05 huntertran

Were you able to solve it? I have the same issue.

bryandandan avatar Oct 19 '20 14:10 bryandandan

Were you able to solve it? I have the same issue.

sorry no

huntertran avatar Oct 20 '20 20:10 huntertran