From 8bf37aad5aa6a8b46f71b5725a36066c5a178b3a Mon Sep 17 00:00:00 2001 From: ogaclejapan Date: Sun, 12 May 2024 17:31:04 +0900 Subject: [PATCH] The code in the "Hello Query" tutorial guide was incorrect The definition of the remember function for the key was missing. --- guide/query/hello-query.md | 6 ++++-- ja/guide/query/hello-query.md | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/guide/query/hello-query.md b/guide/query/hello-query.md index a8d5290..2862e9c 100644 --- a/guide/query/hello-query.md +++ b/guide/query/hello-query.md @@ -60,7 +60,8 @@ Query provides APIs named `rememberXxx` for each type of Key. fun App() { SwrClientProvider(client = swrClient) { MaterialTheme { - when (val query = rememberQuery(HelloQueryKey())) { + val key = remember { HelloQueryKey() } + when (val query = rememberQuery(key)) { is QuerySuccessObject -> Text(query.data) is QueryLoadingObject -> Text("Loading...") is QueryLoadingErrorObject, @@ -87,7 +88,8 @@ fun App() { MaterialTheme { ErrorBoundary(fallback = { Text("Error :(") }) { Suspense(fallback = { Text("Loading...") }) { - val query = rememberQuery(HelloQueryKey()) + val key = remember { HelloQueryKey() } + val query = rememberQuery(key) Await(query) { result -> Text(result) } diff --git a/ja/guide/query/hello-query.md b/ja/guide/query/hello-query.md index 63114ed..9081e9d 100644 --- a/ja/guide/query/hello-query.md +++ b/ja/guide/query/hello-query.md @@ -59,7 +59,8 @@ Query には、 Key のタイプごとに `rememberXxx` という API が用意 fun App() { SwrClientProvider(client = swrClient) { MaterialTheme { - when (val query = rememberQuery(HelloQueryKey())) { + val key = remember { HelloQueryKey() } + when (val query = rememberQuery(key)) { is QuerySuccessObject -> Text(query.data) is QueryLoadingObject -> Text("Loading...") is QueryLoadingErrorObject, @@ -85,7 +86,8 @@ fun App() { MaterialTheme { ErrorBoundary(fallback = { Text("Error :(") }) { Suspense(fallback = { Text("Loading...") }) { - val query = rememberQuery(HelloQueryKey()) + val key = remember { HelloQueryKey() } + val query = rememberQuery(key) Await(query) { result -> Text(result) }