I get this warning from Svelte
State referenced in its own scope will never update. Did you mean to reference it inside a closure?
but the code seems to work fine. Should I be worried about it?
this is the code with the warning:
const filteredOptions = $derived(pluck(["a", "b", "c"], allOptions))
let newFilteredOptions = $state(deepClone(filteredOptions));
let wasModified = $derived(!deepEqual(newFilteredOptions, filteredOptions))
allOptions is global state.
I am taking some props from it, put it in a derived state called filteredOptions and I am expecting allOptions to change its values after I press save, so I want this filter to always have latest values.
Then I create a state var called newFilteredOptions from a clone of filteredOptions which will be used in the bind:input fields.
Then I create another state var to check whether the newFilteredOptions objects differs from the current filteredOptions to determine if I should enable or disable the save button