Anti pattern of svelte. Don’t do this.

Home   »   Anti pattern of svelte. Don’t do this.



{#each stringArray as string} {/each}

  export let value = "";
  
  let privateVariable = Math.random();


{value} - {privateVariable}
## Before
```
Thu May 06 2021 10:53:40 GMT+0900 (대한민국 표준시) - 0.3760519365813768
Thu May 06 2021 10:53:39 GMT+0900 (대한민국 표준시) - 0.47702918806329575
Thu May 06 2021 10:53:37 GMT+0900 (대한민국 표준시) - 0.9880157591341132
```
## After click button
```
Thu May 06 2021 10:53:42 GMT+0900 (대한민국 표준시) - 0.3760519365813768
Thu May 06 2021 10:53:40 GMT+0900 (대한민국 표준시) - 0.47702918806329575
Thu May 06 2021 10:53:39 GMT+0900 (대한민국 표준시) - 0.9880157591341132
Thu May 06 2021 10:53:37 GMT+0900 (대한민국 표준시) - 0.7991972316094662
```
## Expected Result
```
Thu May 06 2021 10:53:42 GMT+0900 (대한민국 표준시) - 0.7991972316094662
Thu May 06 2021 10:53:40 GMT+0900 (대한민국 표준시) - 0.3760519365813768
Thu May 06 2021 10:53:39 GMT+0900 (대한민국 표준시) - 0.47702918806329575
Thu May 06 2021 10:53:37 GMT+0900 (대한민국 표준시) - 0.9880157591341132
```

Leave a Reply

Your email address will not be published. Required fields are marked *