Skip to content

Update relevant DOM element based on signal. #1970

Discussion options

You must be logged in to vote

The reason the effect runs on name change is that the entire cart is in one signal. So when any part of that object is updated anything listening to the signal is updated.

The simple way to solve this is to just use two signals instead of one.

const [name, setName]=createSignal('');
const [cartList, setCartList]=createSignal([{itemName:"", itemPrice:""}]);

Or if you want to keep everything in one object, take a look at the stores api.

https://www.solidjs.com/tutorial/stores_nested_reactivity

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ibtisamarif831
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants