import React, { useState, useEffect } from "react"; // import { SquiggleChart } from "@quri/squiggle-components"; import dynamic from "next/dynamic"; const SquiggleChart = dynamic( () => import("@quri/squiggle-components").then((mod) => mod.SquiggleChart), { loading: () =>

Loading...

, ssr: false, } ); const SquiggleEditor = dynamic( () => import("@quri/squiggle-components").then((mod) => mod.SquiggleEditor), { loading: () =>

Loading...

, ssr: false, } ); // ^ works, but updating the editor content from the outside would be tricky. // and so instead we are hacking our own mini-editor. const effectButtonStyle = "bg-transparent m-2 hover:bg-blue-500 text-blue-700 font-semibold hover:text-white py-2 px-4 border border-blue-500 hover:border-transparent rounded mt-5"; const countNumberOfLines = string => { return string.split("\n").length } export function DynamicSquiggleChart({ element, stopShowing }) { const initialEditorState = !!element ? element.fn : "" const [editorState, setEditorState] = useState(initialEditorState) useEffect(() => { if (!!element && element.fn != "") { setEditorState(element.fn) } }, [element]); if (element == null) { return ""; } else { let usefulElement = { name: element.id, squiggleString: element.fn, binding: element.binding || null }; return (

{usefulElement.name}