Skip to content

Commit

Permalink
docs: Fixed TODO id in animation tutorial (#1108)
Browse files Browse the repository at this point in the history
* Tutorial: Fixed animation id

* Tutorial: Fixed id as key in another file

---------

Co-authored-by: Tee Ming <[email protected]>
  • Loading branch information
F2 and eltigerchino authored Jan 13, 2025
1 parent 17c672a commit 8422db4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
import TodoList from './TodoList.svelte';
const todos = $state([
{ done: false, description: 'write some docs' },
{ done: false, description: 'start writing blog post' },
{ done: true, description: 'buy some milk' },
{ done: false, description: 'mow the lawn' },
{ done: false, description: 'feed the turtle' },
{ done: false, description: 'fix some bugs' }
{ id: 1, done: false, description: 'write some docs' },
{ id: 2, done: false, description: 'start writing blog post' },
{ id: 3, done: true, description: 'buy some milk' },
{ id: 4, done: false, description: 'mow the lawn' },
{ id: 5, done: false, description: 'feed the turtle' },
{ id: 6, done: false, description: 'fix some bugs' }
]);
let uid = todos.length + 1;
function remove(todo) {
const index = todos.indexOf(todo);
todos.splice(index, 1);
Expand All @@ -23,6 +25,7 @@
if (e.key !== 'Enter') return;

todos.push({
id: uid++,
done: false,
description: e.currentTarget.value
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</script>

<ul class="todos">
{#each todos as todo (todo)}
{#each todos as todo (todo.id)}
<li
class={{ done: todo.done }}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</script>

<ul class="todos">
{#each todos as todo (todo)}
{#each todos as todo (todo.id)}
<li
class={{ done: todo.done }}
in:receive={{ key: todo.id }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</script>

<ul class="todos">
{#each todos as todo (todo)}
{#each todos as todo (todo.id)}
<li
class={{ done: todo.done }}
in:receive={{ key: todo.id }}
Expand Down

0 comments on commit 8422db4

Please sign in to comment.