Max @shipit.dev 路 Jan 20

#Svelte folks, I find myself quite often declaring some kind of state (map of booleans or map of dom refs) that is only ever relevant for a single each block. Can I somehow declare this state only within that particular each block? repl: svelte.dev/playground/h... cc @paolo.ricciuti.me

3 likes 4 replies

?

Replies

Max 路 Jan 20

Pretty much something like @const but reactive is what I'm looking for.

{馃И} +paoloricciuti.svelte 路 Jan 20

There's nothing like this but this also feels way to niche to add a whole new concept. If you really want to remove one variable you could use an object in the array instead of the string like this svelte.dev/playground/0...

Sevoris (he/him) 路 Jan 20

Trying to understand this problem: why aren鈥榯 you pushing that state into some component that鈥榮 instantiated N times inside the each block?