nanostores / nanostores

A tiny (286 bytes) state manager for React/RN/Preact/Vue/Svelte with many atomic tree-shakable stores

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Computed behavior changed between 0.8.1 and 0.9.0

peschee opened this issue · comments

Given this example:

const one = atom<string | undefined>(undefined);
const two = computed(one, (value: string | undefined) => !!value);

and this code:

console.log('one', one.get());
console.log('two', two.get());

in 0.8.1, the output / values were

undefined
false

in 0.9.0, the output / values are

undefined
undefined

Is this expected?

Example projects are here:

@TrySound could it be related with your changes?

Yes, notify always forced recomputing before. Now check fails when undefined is compared to out of range index. Need to add array length check additionally.

Good catch @peschee, thanks

Fixing

The fix was released in 0.9.1

Awesome, thanks for a quick fix!