Destructured promise result in {#await} becomes undefined during re-render
See original GitHub issueDescribe the bug Values in a destructured promise result become undefined after a re-render.
<script>
let test = 0;
$: promise = Promise.resolve({ data: 1 });
</script>
{#await promise then { data }}
{#if data}
<button on:click={() => (test = 1)}>Test</button>
{:else}data is {data}{/if}
{/await}
For some reason, having promise defined in a reactive statement was necessary here to reproduce the bug. In my project, I was calling a function in the {#await}
block and passing it a store value.
Logs N/A
To Reproduce https://svelte.dev/repl/3fd4e2cecfa14d629961478f1dac2445?version=3.29.0
Expected behavior I would expect promise results to persist between renders.
Stacktraces N/A
Information about your Svelte project:
-
Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10) Chrome, Firefox
-
Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc) Arch Linux
-
Svelte version (Please check you can reproduce the issue with the latest release!) 3.29.0
-
Whether your project uses Webpack or Rollup N/A
Severity This is annoying, but I can avoid using destructuring here to get around the problem.
Additional context N/A
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (5 by maintainers)
Released you fix in 3.29.3 - https://svelte.dev/repl/3fd4e2cecfa14d629961478f1dac2445?version=3.29.3 - thank you!
sweet!!, I will check now.