MCPcopy Create free account
hub / github.com/electric-sql/electric / Example

Function Example

examples/react/src/Example.tsx:8–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6const baseUrl = import.meta.env.VITE_ELECTRIC_URL ?? `http://localhost:3000`
7
8export const Example = () => {
9 const { data: items } = useShape<Item>({
10 url: `${baseUrl}/v1/shape`,
11 params: {
12 table: `items`,
13 source_id: import.meta.env.VITE_ELECTRIC_SOURCE_ID,
14 secret: import.meta.env.VITE_ELECTRIC_SOURCE_SECRET,
15 },
16 })
17
18 return (
19 <div>
20 {items.map((item: Item, index: number) => (
21 <p key={index} className="item">
22 <code>{item.id}</code>
23 </p>
24 ))}
25 </div>
26 )
27}

Callers

nothing calls this directly

Calls 2

useShapeFunction · 0.90
mapMethod · 0.45

Tested by

no test coverage detected