Comments (3)
In case someone else comes here and is still looking for a solution. Here's how I was able to solve it with the cytoscape-popper
extension and a reference to cytoscape/cytoscape.js-popper#35:
import React, { useEffect, useRef } from 'react';
import ReactDOM from 'react-dom';
import Cytoscape from 'cytoscape';
import CytoscapeComponent from 'react-cytoscapejs';
import popper from 'cytoscape-popper';
import { Button } from 'semantic-ui-react';
Cytoscape.use(popper);
const ReactButton = () => {
return <Button type="button">React Button</Button>;
};
const createContentFromComponent = (component) => {
const dummyDomEle = document.createElement('div');
ReactDOM.render(component, dummyDomEle);
document.body.appendChild(dummyDomEle);
return dummyDomEle;
};
export const OmniGram = () => {
const cyRef = useRef(null);
const cyPopperRef = useRef(null);
useEffect(() => {
const cy = cyRef.current;
cy.nodes().on('mouseover', (event) => {
cyPopperRef.current = event.target.popper({
content: createContentFromComponent(<ReactButton />),
popper: {
placement: 'right',
removeOnDestroy: true,
},
});
});
cy.nodes().on('mouseout', () => {
if (cyPopperRef) {
cyPopperRef.current.destroy();
}
});
}, []);
const elements = {
...
};
return (
<CytoscapeComponent
elements={elements}
cy={(cy) => {
cyRef.current = cy;
}}
/>
);
};
from react-cytoscapejs.
Anything imperative should use the cy
ref.
from react-cytoscapejs.
Ok Thanks
from react-cytoscapejs.
Related Issues (20)
- ReferenceError: window is not defined when refresshing the page.
- Maximum call stack size exceeded HOT 1
- How to use ctxmenu in this component?
- Issues with React 18 StrictMode HOT 4
- Next.js uses cjs module loader resulting in SyntaxError: Cannot use import statement outside a module HOT 2
- TS: cannot find module error
- nodes selction is not working
- Canvas elements moved by 50% to the right of the CytoscapeComponent HOT 2
- v2.0 has demo target missing HOT 7
- resize CytoscapeComponent
- updates to component HOT 2
- Createportal / react-cytoscape HOT 1
- Microbundle Compile Error Next.js HOT 1
- Support automatically check/uncheck link between two nodes
- Question: Could the nodes be interactive? HOT 2
- Question: Update to React 18? HOT 2
- Question: Styling & Layout HOT 1
- Infinite render graph force-directed on parameter "randomize": false
- Module not found: Can't resolve 'react-cytoscapejs' in Nextjs
- findDOMNode is deprecated in StrictMode HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-cytoscapejs.