Skip to content

Commit 43b0d75

Browse files
committed
example updates
1 parent d18e26e commit 43b0d75

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/fragments/lib/datastore/js/data-access/observe-update-snippet.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ function App() {
3535
/**
3636
* Each keypress updates the post in local react state.
3737
*/
38+
if (!post) return;
3839
setPost(
39-
Post.copyOf<Post>(post, (draft) => {
40+
Post.copyOf(post, (draft) => {
4041
draft.title = value;
4142
})
4243
);
@@ -49,6 +50,7 @@ function App() {
4950
/**
5051
* This post is already up to date because observeQuery updated it.
5152
*/
53+
if (!post) return;
5254
await DataStore.save<Post>(post);
5355
console.log("Post saved");
5456
}}

src/fragments/lib/datastore/js/examples.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function onDeleteAll() {
109109
}
110110

111111
async function onQuery() {
112-
const posts: Post[] = await DataStore.query<Post>(Post, (c: Post) => c.rating.gt(4));
112+
const posts: Post[] = await DataStore.query<Post>(Post, (c) => c.rating.gt(4));
113113

114114
console.log(posts);
115115
}

0 commit comments

Comments
 (0)