Readme

tldraw example with builder, for consistent React versions.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/** @jsxImportSource https://esm.sh/react@18.3.1 **/
import build from "https://esm.sh/build";
const ret = await build({
dependencies: {
"react-dom": "18.3.1",
"react": "18.3.1",
"tldraw": "2.3.0",
},
source: `
export * as ReactDOM from "react-dom";
export * as React from "react";
export * as tldraw from "tldraw"
`,
});
const {
ReactDOM,
React,
tldraw,
} = await import(ret.url + "?bundle-deps");
export function App() {
return (
<>
<div style={{ position: "absolute", inset: 0 }}>
<tldraw.Tldraw persistenceKey="valtown_reacttldrawclient" cameraOptions={{ wheelBehavior: "zoom" }} />
</div>
</>
);
}
// The app will be rendered inside the root div
const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
July 22, 2024