svelte-key
v1.0.0
Published
Emulates React's `key` feature: force some content (e.g. some component) to be recreated when the value of the key changes.
Downloads
8
Readme
svelte-key
Emulates React's key
feature: force some content (e.g. some component) to be recreated when the value of the key changes.
This is based on the hack described in this StackOverflow answer (or this comment).
This feature might make it into Svelte eventually. Progress can be tracked in this issue.
Installation
npm install --dev svelte-key
yarn add --dev svelte-key
Usage
<script>
import Identity from 'svelte-key'
let i = 0
</script>
<p>Change input value & click button</p>
<Identity key={i}>
<input />
</Identity>
<button on:click={() => {i++}}>
{i}
</button>