react-force-graph icon indicating copy to clipboard operation
react-force-graph copied to clipboard

change controlType on the go after graph is rendered

Open Kaby-Lake opened this issue 4 years ago • 2 comments

Describe the bug Sir, is there a way to change the controlType on the go. Say after the graph has rendered, I want to switch between different controlType modes. putting the controlType in the state and setState() won't work.

A simplified version of the code:

state = {
      controlType: "trackball" as "trackball" | "orbit" | "fly",
};

<ForceGraph3D
...
controlType={this.state.controlType}

onBackgroundClick={() => {
       this.setState({
            controlType: "fly",
       });
}}
/>

Kaby-Lake avatar Feb 25 '21 12:02 Kaby-Lake

@Kaby-Lake I'm afraid this is not possible. The controlType is a static prop. Changing it after component instantiation will have no effect.

vasturiano avatar Feb 25 '21 14:02 vasturiano

ok, thanks for your help, I may end up with creating 3 different components with 3 static controlTypes

Kaby-Lake avatar Feb 26 '21 02:02 Kaby-Lake