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

[Typescipt Import]

Open SherloqueChang opened this issue 4 years ago • 3 comments

For the example given in Github, .js files are imported in HTML using like:

  <script src="//unpkg.com/react/umd/react.production.min.js"></script>
  <script src="//unpkg.com/react-dom/umd/react-dom.production.min.js"></script>
  <script src="//unpkg.com/babel-standalone"></script>

However, if I'd like to import them in a react+typescript project, what should I do?

SherloqueChang avatar Aug 07 '21 02:08 SherloqueChang

If you're using ES modules, you can just do f.e.

import ForceGraph3D from 'react-force-graph-3d';

There's more info about importing this module in the readme.

vasturiano avatar Aug 08 '21 10:08 vasturiano

Yead, it works for 'react-force-graph-3d'. However, here is a specific example: https://github.com/vasturiano/react-force-graph/blob/master/example/text-links/index-3d.html#L28 Since I don't how to deal with<script src="//unpkg.com/three-spritetext"></script> in a .tsx file, error 'Cannot find name 'SpriteText'' is reported.

SherloqueChang avatar Aug 08 '21 12:08 SherloqueChang

That's for an import from another module: https://github.com/vasturiano/three-spritetext

vasturiano avatar Aug 08 '21 23:08 vasturiano