I'm using the following code in Svelte (3) to fetch options from an API. There's subsequent s that depend on the first one. My expectation is that selectedOption would change to options[0] when the select has its options populated but it's not changing until I manually select another option and then select the first one. Am I binding it wrong? AFAIK I don't need a reactive variable for this and should theoretically work like this.
onmount(async () => {
options = await getOptions()
})
let selectedOption;
<select bind:value={selectedOption}>
{#each options as option}
<option value={option} selected={selectedOption === option}>
{option.name}
</option>
{/each}