MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / ExamplePage

Function ExamplePage

packages/plugins/example/src/client.tsx:22–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20const greetAtom = ExampleClient.mutation("example", "greet");
21
22function ExamplePage() {
23 const [name, setName] = useState("world");
24 const [result, setResult] = useState<string>();
25 const doGreet = useAtomSet(greetAtom, { mode: "promise" });
26
27 return (
28 <div style={{ maxWidth: 480, margin: "2rem auto", padding: "1rem" }}>
29 <h1 style={{ fontSize: "1.25rem", marginBottom: "1rem" }}>Example plugin</h1>
30 <div style={{ display: "flex", gap: 8 }}>
31 {/* The example plugin demonstrates the SDK in isolation, so it
32 uses raw HTML controls instead of `@executor-js/react`'s
33 wrapped components — third-party plugin authors don't have
34 to depend on the host's component library. */}
35 {/* oxlint-disable-next-line react/forbid-elements */}
36 <input
37 value={name}
38 onChange={(e) => setName(e.target.value)}
39 style={{
40 flex: 1,
41 padding: "0.5rem 0.75rem",
42 border: "1px solid #ccc",
43 borderRadius: 6,
44 }}
45 />
46 {/* oxlint-disable-next-line react/forbid-elements */}
47 <button
48 type="button"
49 onClick={async () => {
50 // Mutation has no shared state to invalidate — explicit
51 // empty `reactivityKeys` documents the intent for the
52 // `require-reactivity-keys` rule.
53 const g = await doGreet({ payload: { name }, reactivityKeys: [] });
54 setResult(`${g.message} (#${g.count})`);
55 }}
56 style={{
57 padding: "0.5rem 0.75rem",
58 border: "1px solid #ccc",
59 borderRadius: 6,
60 cursor: "pointer",
61 }}
62 >
63 Greet
64 </button>
65 </div>
66 {result && (
67 <pre style={{ marginTop: "1rem", padding: "0.5rem", background: "#f5f5f5" }}>{result}</pre>
68 )}
69 </div>
70 );
71}
72
73export default defineClientPlugin({
74 id: "example" as const,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected