3 ms·
One bit of feedback: Its always appreciated when code examples on websites are complete. Your example isn't complete -- where's the `transact` import coming fro
by sibeliuss 2y ago
One bit of feedback: Its always appreciated when code examples on websites are complete. Your example isn't complete -- where's the `transact` import coming from, or `useQuery`? Little minor details that go far as your product scales out to a wider user base.
- lelo_tp 2y agolol i was wondering the same thing
- krehwell 2y agothis is my question too, lol
- stopachka 2y agoThank you for the feedback, this makes sense! I updated the example to include the imports: ``` import { init, tx, id } from "@instantdb/react"; const db = init({ appId: process.env.NEXT_PUBLIC_APP_ID, }); function Chat() { // 1. Read const { isLoading, error, data } = db.useQuery({ messages: {}, }); // 2. Write const addMessage = (message) => { db.transact(tx.messages[id()].update(message)); }; // 3. Render! return <UI data={data} onAdd={addMessage} />; } ``` What do you think?
- sibeliuss 2y agoMuch better!
- android521 2y agoYes. This gives users the vibe of “ this is obvious, if you don’t know it , you are dumb “ .
- ElFitz 2y agoOr that the writers were oblivious, and the documentation shouldn’t be relied upon.
- iosguyryan 2y agoI usually read: you have so few users / care so little that I shouldn’t trust you because you’d have heard this complaint and fixed it. But in this case it was fixed up quickly. Which is great