Ziltoid
Ziltoid
SSolidJS
Created by Ziltoid on 8/5/2023 in #support
How do I modify a member of an object in an array in a SolidJS Store using the SetStoreFunction?
(Re-post from https://stackoverflow.com/questions/76843586/how-do-i-modify-a-member-of-an-object-in-an-array-in-a-solidjs-store-using-the-s , if answered here or vice versa I'll update the other ) Full code is in the stack overflow link^ I'm trying to modify an element of a SolidJS store using the SetStoreFunction (setExpressions). The SetStoreFunction accepts 'Path Syntax' as described in the docs: https://www.solidjs.com/docs/latest/api#updating-stores , so I am trying to do something similar here, but it doesn't work:
const [expressions, setExpressions] = createStore<Expression[]>([])

(...)

setExpressions( //todo the problem seems to be here somewhere:
expression => expression.id == id, // first we filter the array to those Expression objects which match the id specified
'value', // Then we select the value member of Expression
value // Then we pass the new value to be set
)
const [expressions, setExpressions] = createStore<Expression[]>([])

(...)

setExpressions( //todo the problem seems to be here somewhere:
expression => expression.id == id, // first we filter the array to those Expression objects which match the id specified
'value', // Then we select the value member of Expression
value // Then we pass the new value to be set
)
I've tried double checking the path syntax for SetStoreFunction (setExpressions) against the docs, and I still believe it should work. In the full code, I'm expecting that when I call getExpressionSetValue(id), it returns a setValue string => void function on the expression with that id. And that I can call setValue("abc") to set the value on that expression to abc. This should allow me to type into the text field to update the value. But instead no change happens when I type into the text field. I'm also not sure how to dive deeper into debugging this issue (kinda new to web dev) so I'm open to suggestions there as well (leave a comment? many thanks). Any thoughts?
12 replies
SSolidJS
Created by Ziltoid on 4/19/2023 in #support
Derived Signals vs Memos
Noob here; I'm going through the intro tutorial and I want to make sure I fully understand derived signals and memos. It seems like there are only upsides to memos over derived signals. (I am thinking along the lines of, if memos are only superior, why use derived signals at all?) So I have some questions: 1. What are the downsides of memos compared to derived signals? 2. Where would I want to use a derived signal instead of a memo?
5 replies