From 2ed5cd9e442196d1ae1a320a7f8e8b0359c3f9f3 Mon Sep 17 00:00:00 2001 From: freddie Date: Sat, 16 Sep 2023 17:09:43 +0100 Subject: [PATCH] docs: formatting --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b38a0a2..341be7d 100644 --- a/README.md +++ b/README.md @@ -49,14 +49,9 @@ const loader = makeLoader(async () => { }); }); -> **Note** -> You will have to `await` swr so that the ui-blocking part can be resolved (the cache) prior to rendering, but the fresh data will still be sent as an unfulfilled promise. - -See the full example [here](/examples/vite-react). - // automatically handles cached data, loading states, and errors, obeys `onError` behaviour const Component = () => { - const { posts } = useLoaderData(); +const { posts } = useLoaderData(); return { loadingElement={} // will render if there’s an error loading the data and there is no cache errorElement={} - > - {posts =>
    {posts.map(posts =>
  • {post.title}
  • )}
} + > + {posts =>
    {posts.map(posts =>
  • {post.title}
  • )}
}
+ } + ``` +> **Note** +> You will have to `await` swr so that the ui-blocking part can be resolved (the cache) prior to rendering, but the fresh data will still be sent as an unfulfilled promise. + +See the full example [here](/examples/vite-react). + ### Invalidating the cache You can use invalidation as part of actions or simply call it in your event handlers, if your app is not server-side rendered.