← Back to context

Comment by sibeliuss

2 years 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.

Thank 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?

Yes. This gives users the vibe of “ this is obvious, if you don’t know it , you are dumb “ .

  • Or that the writers were oblivious, and the documentation shouldn’t be relied upon.

    • I 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