title: Getting undefined when updating array in stores using Svelte
body: <p>I am learning Svelte and how to make custom stores using it. I've come across a problem where when I try to update a writable array using update, it causes an undefined error in components that subscribe to the array.</p>
  <p>Here is my store where I have a simple array with one element, a string:</p>
  <pre><code>import { writable } from 'svelte/store'
  
  export const activeData = writable([&quot;array&quot;])
  </code></pre>
  <p>Here is a component that updates the store. I am simply pushing the word &quot;pushed&quot; to the activeData array:</p>
  <pre><code>&lt;script&gt;
  import {activeData} from './Store.js'
  
  let handlePush = ()=&gt;{
      activeData.update(val=&gt;{val.push('pushed!')
      val = val
  }
      )
  }
  
  &lt;/script&gt;
  
  &lt;button
  on:click={handlePush}&gt;
  push
  &lt;/button&gt;
  </code></pre>
  <p>And then in this app.svelte component, I am subscribing to activeData and hoping to print the elements of the activeData array using Svelte's #each directive:</p>
  <pre><code>&lt;script&gt;
      import {activeData} from './Store.js'
      import Push from './Push.svelte'
      
  
  &lt;/script&gt;
  
  &lt;div&gt;
     {#each $activeData as datum}
      &lt;p&gt;{datum}&lt;/p&gt;
      {/each}
  
      {@debug $activeData}
  &lt;/div&gt;
  
  &lt;Push/&gt;
  
  </code></pre>
  <p>When I check the console for activeData, I see that it updates by adding &quot;Push!&quot; to the array. However, I then get an error in my app.svelte component saying &quot;Error: {#each} only iterates over array-like objects.&quot;</p>
  <p>So after updating the array, the array is no longer an array to components subscribing to it.</p>
  <p>Any idea why this is happening?</p>