Skip to content

Commit

Permalink
feat: add button to call library method
Browse files Browse the repository at this point in the history
  • Loading branch information
egenerse committed Dec 18, 2024
1 parent a5ff2de commit 0617bbc
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions standalone/webapp/src/LibraryView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ export function LibraryView() {
const containerRef = useRef<HTMLDivElement | null>(null)
const apollon2Ref = useRef<Apollon2 | null>(null)

const onGetNodesButtonClick = () => {
// To show that the getNodes method works
if (apollon2Ref.current) {
console.log(apollon2Ref.current.getNodes())
}
}
useLayoutEffect(() => {
if (containerRef.current) {
apollon2Ref.current = new Apollon2(containerRef.current)

console.log(
"Random number from Apollon2:",
apollon2Ref.current.getNodes()
)
}

return () => {
Expand All @@ -25,5 +26,15 @@ export function LibraryView() {
}
}, [])

return <div ref={containerRef} style={{ width: "100vw", height: "100vh" }} />
return (
<>
<button
onClick={onGetNodesButtonClick}
style={{ position: "absolute", top: "0", left: "0", zIndex: 1000 }}
>
Get Nodes
</button>
<div ref={containerRef} style={{ width: "100vw", height: "100vh" }} />
</>
)
}

0 comments on commit 0617bbc

Please sign in to comment.