#Updating every instance of the same component

2 messages · Page 1 of 1 (latest)

lucid canopy
#

Hi there,

I want to build a component, which renders depending on a Signal (this works).
I have two buttons in the component:
Button 1: Should set the Signal to change the output only of this component (that works)
Button 2: Should set the Signal to change the output of all instances of the component (that does not work) and it should save the state to localStorage to remember the state after a reload (that works again)

I added createStore in the hope that the State will be shared between all the components, but this doesn't work as I hope it will.

I build a example here: https://codesandbox.io/p/sandbox/sweet-tamas-6ehys0

What am I doing wrong?

Kind regards
hansrouge

hazy mist
#

Not so deep into solid, but you are defining the store in the component and as far as I understand the docs, the store needs to be created outside of the component and needs to be imported in the component to have a shared store, like https://www.solidjs.com/tutorial/stores_nocontext shows.

Solid is a purely reactive library. It was designed from the ground up with a reactive core. It's influenced by reactive principles developed by previous libraries.