3 ms·
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 =
by stopachka 2y ago
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?
- sibeliuss 2y agoMuch better!