Skip to content

Commit 62c3fa0

Browse files
authored
doc: update example
1 parent f464176 commit 62c3fa0

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ Visit the [REPL demo](https://svelte.dev/repl/1d3e752c51b848e6af264f3244f3e85c?v
3131
```svelte
3232
<script>
3333
import { withPrevious } from 'svelte-previous';
34+
35+
export let name;
3436
// current is writable, while previous is read-only.
35-
const [current, previous] = withPrevious(0);
37+
const [currentName, previousName] = withPrevious(0);
3638
// To update the values, assign to the writable store.
37-
setInterval(() => $current++, 1000);
39+
$: $currentName = name;
3840
</script>
3941
40-
from {$previous} to {$current}.
42+
transition from {$previousName} to {$currentName}.
4143
```
4244

4345
## Options
@@ -53,7 +55,6 @@ To track more than one value, set `numToTrack`.
5355
```svelte
5456
<script>
5557
const [current, prev1, prev2] = withPrevious(0, { numToTrack: 2 });
56-
setInterval(() => $current++, 1000);
5758
</script>
5859
5960
from {$prev2} to {$prev1} to {$current}.

0 commit comments

Comments
 (0)