SolidJSS
SolidJS2y ago
6 replies
MikeM42

createStore doesn't signal with a class as the store, but everything else works.

If I creatgeStore using a class: letss say a simple class like this one:
class TryMe { 'tryswitch'?: boolean } ... const [simpleTest, setSimpleTest] = createStore(new TryMe());

Then accessing and setting via setSimpleTest and simpleTest work fine. But when I set the "tryswitch" value there iss no signal being generated.
So this code:

<div class="field"> <div class="control has-text-left my-5"> <input id="switch" type="checkbox" name="switchExample" class="switch is-rounded" checked={simpleValue.tryswitch} onChange={(event) => setSimpleValue("tryswitch", event.currentTarget.checked)} /> <label for="switch"><span class="mx-2 has-text-weight-semibold">Switch</span></label> </div> </div> <Show when={simpleValue.tryswitch}> <SomeComponent.../> </Show>
So the SomeComponent doesn't dynamically show when I change the myswitch value.

On the other hand if instead of a simple class I use the below then it works:
const [simpleTest, setSimpleTest] = createStore({ myswitch: false });

Is this to be expected, is it hard to make it work with a class?
Was this page helpful?