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

[Typescript] Functional components and ReactDom

Open jonathan-irvin opened this issue 4 years ago • 2 comments

Hey @vasturiano!

I noticed on many of your examples, they're using jsx and on some you are referencing the components as functions. Do you have an example of this in Typescript?

Also, I notice that you generally split the graph into a separate div element. Do you have an example where it shares the same root div as React does?

jonathan-irvin avatar May 20 '20 14:05 jonathan-irvin

Hi @jonathan-irvin,

I suppose you're referring to this method of invoking React render: https://github.com/vasturiano/react-force-graph/blob/master/example/click-to-focus/index.html#L43-L46

I can imagine it's no different when using Typescript, other than the file should have a .tsx extension. In any case, it is more of a typescript+react type of question and not specific to this lib.

I'm not sure I fully understand your 2nd question about the root div, could you elaborate?

vasturiano avatar May 21 '20 03:05 vasturiano

Regarding the second question, I think he means the following if it's possible

ReactDOM.render(
  <ForceGraph2d />,
  document.getElementById('root')
);

varqasim avatar Jun 04 '20 15:06 varqasim