```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. function App() { const [post, setPost] = useState(); useEffect(() => { /** * This keeps `post` fresh. */ const sub = DataStore.observeQuery(Post, (c) => c.id.eq('e4dd1dc5-e85c-4566-8aaa-54a801396456') ).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 ( <>