From 0e19273afd9d2cce8450f768edb26d0a3ed0b3c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=BC=97=E8=B1=AA?= Date: Sun, 4 Feb 2024 17:06:52 +0800 Subject: [PATCH] docs: The code for tutorial/stores_nested_reactivity is consistent with en --- langs/de/tutorials/stores_nested_reactivity/lesson.md | 3 +-- langs/de/tutorials/stores_nested_reactivity/solved.json | 2 +- langs/it/tutorials/stores_nested_reactivity/lesson.md | 3 +-- langs/it/tutorials/stores_nested_reactivity/solved.json | 2 +- langs/ja/tutorials/stores_nested_reactivity/lesson.md | 3 +-- langs/ja/tutorials/stores_nested_reactivity/solved.json | 2 +- langs/ru/tutorials/stores_nested_reactivity/lesson.md | 3 +-- langs/ru/tutorials/stores_nested_reactivity/solved.json | 2 +- langs/zh-cn/tutorials/stores_nested_reactivity/lesson.md | 3 +-- langs/zh-cn/tutorials/stores_nested_reactivity/solved.json | 2 +- 10 files changed, 10 insertions(+), 15 deletions(-) diff --git a/langs/de/tutorials/stores_nested_reactivity/lesson.md b/langs/de/tutorials/stores_nested_reactivity/lesson.md index d1587524..857f7449 100644 --- a/langs/de/tutorials/stores_nested_reactivity/lesson.md +++ b/langs/de/tutorials/stores_nested_reactivity/lesson.md @@ -23,8 +23,7 @@ Jetzt können wir den Erledigungszustand aktualisieren, indem wir `setCompleted` ```js const toggleTodo = (id) => { - const index = todos().findIndex((t) => t.id === id); - const todo = todos()[index]; + const todo = todos().find((t) => t.id === id); if (todo) todo.setCompleted(!todo.completed()) } ``` diff --git a/langs/de/tutorials/stores_nested_reactivity/solved.json b/langs/de/tutorials/stores_nested_reactivity/solved.json index e4190ad0..40223ce6 100644 --- a/langs/de/tutorials/stores_nested_reactivity/solved.json +++ b/langs/de/tutorials/stores_nested_reactivity/solved.json @@ -2,7 +2,7 @@ "files": [ { "name": "main", - "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" + "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" } ] } diff --git a/langs/it/tutorials/stores_nested_reactivity/lesson.md b/langs/it/tutorials/stores_nested_reactivity/lesson.md index bc48af9f..8a3a54c6 100644 --- a/langs/it/tutorials/stores_nested_reactivity/lesson.md +++ b/langs/it/tutorials/stores_nested_reactivity/lesson.md @@ -23,8 +23,7 @@ Now we can update the completion state by calling `setCompleted` without any add ```js const toggleTodo = (id) => { - const index = todos().findIndex((t) => t.id === id); - const todo = todos()[index]; + const todo = todos().find((t) => t.id === id); if (todo) todo.setCompleted(!todo.completed()) } ``` diff --git a/langs/it/tutorials/stores_nested_reactivity/solved.json b/langs/it/tutorials/stores_nested_reactivity/solved.json index e4190ad0..40223ce6 100644 --- a/langs/it/tutorials/stores_nested_reactivity/solved.json +++ b/langs/it/tutorials/stores_nested_reactivity/solved.json @@ -2,7 +2,7 @@ "files": [ { "name": "main", - "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" + "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" } ] } diff --git a/langs/ja/tutorials/stores_nested_reactivity/lesson.md b/langs/ja/tutorials/stores_nested_reactivity/lesson.md index 1aadf450..2206a65e 100644 --- a/langs/ja/tutorials/stores_nested_reactivity/lesson.md +++ b/langs/ja/tutorials/stores_nested_reactivity/lesson.md @@ -23,8 +23,7 @@ const addTodo = (text) => { ```js const toggleTodo = (id) => { - const index = todos().findIndex((t) => t.id === id); - const todo = todos()[index]; + const todo = todos().find((t) => t.id === id); if (todo) todo.setCompleted(!todo.completed()) } ``` diff --git a/langs/ja/tutorials/stores_nested_reactivity/solved.json b/langs/ja/tutorials/stores_nested_reactivity/solved.json index e4190ad0..40223ce6 100644 --- a/langs/ja/tutorials/stores_nested_reactivity/solved.json +++ b/langs/ja/tutorials/stores_nested_reactivity/solved.json @@ -2,7 +2,7 @@ "files": [ { "name": "main", - "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" + "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" } ] } diff --git a/langs/ru/tutorials/stores_nested_reactivity/lesson.md b/langs/ru/tutorials/stores_nested_reactivity/lesson.md index 81a00d80..ed9a30d6 100644 --- a/langs/ru/tutorials/stores_nested_reactivity/lesson.md +++ b/langs/ru/tutorials/stores_nested_reactivity/lesson.md @@ -23,8 +23,7 @@ const addTodo = (text) => { ```js const toggleTodo = (id) => { - const index = todos().findIndex((t) => t.id === id); - const todo = todos()[index]; + const todo = todos().find((t) => t.id === id); if (todo) todo.setCompleted(!todo.completed()) } ``` diff --git a/langs/ru/tutorials/stores_nested_reactivity/solved.json b/langs/ru/tutorials/stores_nested_reactivity/solved.json index e4190ad0..40223ce6 100644 --- a/langs/ru/tutorials/stores_nested_reactivity/solved.json +++ b/langs/ru/tutorials/stores_nested_reactivity/solved.json @@ -2,7 +2,7 @@ "files": [ { "name": "main", - "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" + "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" } ] } diff --git a/langs/zh-cn/tutorials/stores_nested_reactivity/lesson.md b/langs/zh-cn/tutorials/stores_nested_reactivity/lesson.md index 034cc398..321445ce 100644 --- a/langs/zh-cn/tutorials/stores_nested_reactivity/lesson.md +++ b/langs/zh-cn/tutorials/stores_nested_reactivity/lesson.md @@ -23,8 +23,7 @@ const addTodo = (text) => { ```js const toggleTodo = (id) => { - const index = todos().findIndex((t) => t.id === id); - const todo = todos()[index]; + const todo = todos().find((t) => t.id === id); if (todo) todo.setCompleted(!todo.completed()) } ``` diff --git a/langs/zh-cn/tutorials/stores_nested_reactivity/solved.json b/langs/zh-cn/tutorials/stores_nested_reactivity/solved.json index e4190ad0..40223ce6 100644 --- a/langs/zh-cn/tutorials/stores_nested_reactivity/solved.json +++ b/langs/zh-cn/tutorials/stores_nested_reactivity/solved.json @@ -2,7 +2,7 @@ "files": [ { "name": "main", - "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const index = todos().findIndex((t) => t.id === id);\n const todo = todos()[index];\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" + "content": "import { render } from \"solid-js/web\";\nimport { For, createSignal } from \"solid-js\";\n\nconst App = () => {\n const [todos, setTodos] = createSignal([])\n let input;\n let todoId = 0;\n\n const addTodo = (text) => {\n const [completed, setCompleted] = createSignal(false); \n setTodos([...todos(), { id: ++todoId, text, completed, setCompleted }]);\n }\n const toggleTodo = (id) => {\n const todo = todos().find((t) => t.id === id);\n if (todo) todo.setCompleted(!todo.completed())\n }\n\n return (\n <>\n
\n \n {\n if (!input.value.trim()) return;\n addTodo(input.value);\n input.value = \"\";\n }}\n >\n Add Todo\n \n
\n \n {(todo) => {\n const { id, text } = todo;\n console.log(`Creating ${text}`)\n return
\n \n {text}\n
\n }}\n
\n \n );\n};\n\nrender(App, document.getElementById(\"app\"));\n" } ] }