{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import ipyreact\n", "from traitlets import List, Any\n", "import numpy as np\n", "\n", "class TldrawSineWidget(ipyreact.ReactWidget):\n", " points = List(List(Any())).tag(sync=True)\n", " _esm = \"\"\"\n", " import { TDShapeType, Tldraw } from \"@tldraw/tldraw\";\n", " import * as React from \"react\";\n", "\n", " export default function App({ points }) {\n", "\n", " const [app, setApp] = React.useState()\n", "\n", " const handleMount = React.useCallback((app: Tldraw) => {\n", " setApp(app)\n", " }, []);\n", "\n", " React.useEffect(() => {\n", " if (app) {\n", " app.createShapes({\n", " type: \"draw\",\n", " id: \"draw1\",\n", " color: 'red',\n", " points: points,\n", " });\n", " }\n", " }, [points, app])\n", "\n", " return (\n", "