Back

Version 2

6/5/2024
/** @jsxImportSource https://esm.sh/react **/
import ReactDOM from "https://esm.sh/react-dom";
import React, { useRef, useEffect } from "https://esm.sh/react@18.0.0";
import { Tldraw } from "https://esm.sh/tldraw@2.1.0";
// import "https://esm.sh/tldraw/tldraw.css";

export function App() {
const tldrawRef = useRef(null);

useEffect(() => {
if (tldrawRef.current) {
console.log("Tldraw is ready");
}
}, [tldrawRef.current]);

return (
<>
<div style={{ position: "fixed", inset: 0 }}>
<Tldraw ref={tldrawRef} />
</div>
</>
);
}

// The app will be rendered inside the root div
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
Updated: June 5, 2024