```js // Example showing how to observe the model and keep state updated before // performing a save. This uses the useEffect React hook, but you can // substitute for a similar mechanism in your application lifecycle with // other frameworks. const App = () => { const [post, setPost] = useState(); useEffect(() => { /** * This keeps `post` fresh. */ const sub = DataStore.observeQuery(Post, (c) => c.id.eq('5a3b284c-8afc-436a-9027-c8c32bfc8ed2') ).subscribe(({ items }) => { setPost(items[0]); }); return () => { sub.unsubscribe(); }; }, []); /** * Create a new Post */ async function onCreate() { const _post = await DataStore.save( new Post({ title: `New title ${Date.now()}`, rating: Math.floor(Math.random() * (8 - 1) + 1), status: PostStatus.ACTIVE }) ); setPost(_post); } return ( {post?.title}