Closed sim51 closed 2 years ago
When I did
useEffect(() => {
const container = sigmaContext.container
...
I got an error saying that the node which I'm trying to insert before is not a child of the current node.
But when I use const container = document.getElementsByClassName('sigma-container')[0]
instead, it works.
in v2, the context is now exported : https://github.com/sim51/react-sigma/blob/main/packages/core/src/index.ts#L7
The only way to have access to the sigma container is to search it by its className (ie.
sigma-container
). But the container is stored inside the context of the lib : https://github.com/sim51/react-sigma-v2/blob/1.3.0/src/context.ts#L6Solution : add a hook to have access to the sigma container or expose the context of the lib. I prefer solution 1, so the lib context is only for internal purpose, and I can expose what I really want