Skip to main content

useVisuallyJsUpdate

useVisuallyJsUpdate(callback): void

Simple hook that responds to all update events in the model, including when the model is cleared. You pass in a function that takes the model as argument, and that should be invoked when an update/clear event occurs. The function is also invoked when the initial model reference is obtained.

import { useVisuallyJsUpdate } from "@visuallyjs/browser-ui-react"
import { useState } from "react"

export default function NodeCount() {
const [count, setCount] = useState(0)
useVisuallyJsUpdate((model) => setCount(model.getNodeCount()))
return <h1>{count}</h1>
}

Parameters

callback

(model) => any

Callback to invoke when an update occurs.

Returns

void