react-force-graph
react-force-graph copied to clipboard
Question: can i return JSX to the nodeLabel prop in 3D
I want to render a React component in the nodeLabel prop
@BarrieLAJ sorry that isn't currently supported. The longer answer is because this module is simply a React wrapper around 3d-force-graph, which is where the rendering takes place, and that is not aware of JSX syntax.
But, you can still pass HTML-like syntax in string format, like so:
.nodeLabel(node => `Node <b>${node.id}</b>`)
@BarrieLAJ sorry that isn't currently supported. The longer answer is because this module is simply a React wrapper around 3d-force-graph, which is where the rendering takes place, and that is not aware of JSX syntax.
But, you can still pass HTML-like syntax in string format, like so:
.nodeLabel(node => `Node <b>${node.id}</b>`)
Okay that makes sense.
I used the
ReactDOMServer.renderToString()
method to convert my components to HTML string.
Here is the Docs reference. https://reactjs.org/docs/react-dom-server.html