Skip to content

Commit 8422db4

Browse files
F2eltigerchino
andauthored
docs: Fixed TODO id in animation tutorial (sveltejs#1108)
* Tutorial: Fixed animation id * Tutorial: Fixed id as key in another file --------- Co-authored-by: Tee Ming <[email protected]>
1 parent 17c672a commit 8422db4

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

apps/svelte.dev/content/tutorial/02-advanced-svelte/05-advanced-transitions/01-deferred-transitions/+assets/app-a/src/lib/App.svelte

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
import TodoList from './TodoList.svelte';
33
44
const todos = $state([
5-
{ done: false, description: 'write some docs' },
6-
{ done: false, description: 'start writing blog post' },
7-
{ done: true, description: 'buy some milk' },
8-
{ done: false, description: 'mow the lawn' },
9-
{ done: false, description: 'feed the turtle' },
10-
{ done: false, description: 'fix some bugs' }
5+
{ id: 1, done: false, description: 'write some docs' },
6+
{ id: 2, done: false, description: 'start writing blog post' },
7+
{ id: 3, done: true, description: 'buy some milk' },
8+
{ id: 4, done: false, description: 'mow the lawn' },
9+
{ id: 5, done: false, description: 'feed the turtle' },
10+
{ id: 6, done: false, description: 'fix some bugs' }
1111
]);
1212
13+
let uid = todos.length + 1;
14+
1315
function remove(todo) {
1416
const index = todos.indexOf(todo);
1517
todos.splice(index, 1);
@@ -23,6 +25,7 @@
2325
if (e.key !== 'Enter') return;
2426

2527
todos.push({
28+
id: uid++,
2629
done: false,
2730
description: e.currentTarget.value
2831
});

apps/svelte.dev/content/tutorial/02-advanced-svelte/05-advanced-transitions/01-deferred-transitions/+assets/app-a/src/lib/TodoList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</script>
44

55
<ul class="todos">
6-
{#each todos as todo (todo)}
6+
{#each todos as todo (todo.id)}
77
<li
88
class={{ done: todo.done }}
99
>

apps/svelte.dev/content/tutorial/02-advanced-svelte/05-advanced-transitions/01-deferred-transitions/+assets/app-b/src/lib/TodoList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</script>
66

77
<ul class="todos">
8-
{#each todos as todo (todo)}
8+
{#each todos as todo (todo.id)}
99
<li
1010
class={{ done: todo.done }}
1111
in:receive={{ key: todo.id }}

apps/svelte.dev/content/tutorial/02-advanced-svelte/05-advanced-transitions/02-animations/+assets/app-b/src/lib/TodoList.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</script>
77

88
<ul class="todos">
9-
{#each todos as todo (todo)}
9+
{#each todos as todo (todo.id)}
1010
<li
1111
class={{ done: todo.done }}
1212
in:receive={{ key: todo.id }}

0 commit comments

Comments
 (0)