preact-www icon indicating copy to clipboard operation
preact-www copied to clipboard

REPL: Bug with `effect` & `useSignalEffect` tracking

Open rschristian opened this issue 1 year ago • 0 comments

Not quite sure of the cause & don't have time to chase it down yet, but the tracking of dependencies in effect and useSignalEffect seems to be a bit broken in the context of our REPL. For example, here's a lazy effect:

import { signal, effect, useSignalEffect } from '@preact/signals';

const count = signal(0);
const initialized = signal(false);

effect(() => {
	count.value;
	if (!initialized.peek()) return initialized.value = true;
	console.log(count.value)
});

count.value++;

The effect here will not subscribe to count, even though it's explicitly accessed. Swapping that to count.value.toString() works, however.

rschristian avatar Sep 23 '24 18:09 rschristian