Skip to content

Commit

Permalink
Merge pull request #5 from soil-kt/fix_query_code
Browse files Browse the repository at this point in the history
The code in the "Hello Query" tutorial guide was incorrect
  • Loading branch information
ogaclejapan authored May 12, 2024
2 parents 30a2226 + 8bf37aa commit 584b09e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions guide/query/hello-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
Expand Down
6 changes: 4 additions & 2 deletions ja/guide/query/hello-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
}
Expand Down

0 comments on commit 584b09e

Please sign in to comment.