How can objects defined by react in componentDidMount be used in other submissions such as handleSubmit?


class Demo extends Component {
    handleSubmit = () => {
        //  chart 
    
    }
    componentDidMount() {
        // 
        var chart = new G2.Chart({
             container: "dashboardChange",
             forceFit: true,
        });
    }
    }
Apr.23,2021

can't you just write like this


this.chart = {...}

then you can get this.chart globally

Menu