You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
A stackoverflow question: [(https://stackoverflow.com/questions/58226319/assignment-into-a-variable-used-as-an-event-handler-is-not-reactive)] raises an issue of a variable used as an event handler does not update.
<script>
let count = 0;
let handler = () => {};
function update() {
if (count >= 3) {handler = () => {count = 0;}}
count++;
}
setInterval(update, 1000);
</script>
<h1 on:click={handler}>{count}</h1>
From code, handler and count both are props and the h1 element uses, but handler does not update the on:click action.
Note that this may just be a succinct example of #3040.
To Reproduce
Visit this REPL, wait three seconds and click the number:
Describe the bug
A stackoverflow question: [(https://stackoverflow.com/questions/58226319/assignment-into-a-variable-used-as-an-event-handler-is-not-reactive)] raises an issue of a variable used as an event handler does not update.
From code,
handler
andcount
both are props and the h1 element uses, but handler does not update the on:click action.Note that this may just be a succinct example of #3040.
To Reproduce
Visit this REPL, wait three seconds and click the number:
https://svelte.dev/repl/cb0469ba5d8241e382677ad95a659b76?version=3.12.1
The text was updated successfully, but these errors were encountered: