Skip to content

Instantly share code, notes, and snippets.

@sverhoeven
Created October 2, 2020 10:12
Show Gist options
  • Save sverhoeven/248014c06cacaf2f65f5885eb3e266fe to your computer and use it in GitHub Desktop.
Save sverhoeven/248014c06cacaf2f65f5885eb3e266fe to your computer and use it in GitHub Desktop.
run-cpp-on-web: kitchen-sink
function IterationsPlot({ iterations }) {
const container = React.useRef(null);
function didUpdate() {
if (container.current === null || iterations.length === 0) {
return;
}
const spec = iterations2spec(iterations);
vegaEmbed(container.current, spec);
}
const dependencies = [container, iterations];
React.useEffect(didUpdate, dependencies);
return <div ref={container} />;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment