Eugen
Eugen
SSolidJS
Created by Eugen on 4/29/2024 in #support
Does the createMemo() in the "Solid in 100 secs" vid make sense?
Hi - I just stumbled upon Solid, and the two introductory vids really made me curious, coming from React. I just wonder if the createMemo() usage in the video makes sense, assuming computation was really heavy. Because I would think that squared only gets recomputed when its dependencies - count in this case - change. Here's the code:
function Counter() {
const [count, setCount] = createSignal (10);
const squared = createMemo (() => count () ** 2);
return <p>{ squared() }</p>
}
function Counter() {
const [count, setCount] = createSignal (10);
const squared = createMemo (() => count () ** 2);
return <p>{ squared() }</p>
}
I can see though that it makes sense if there is an A - B - A change of count. In that case, the computation would not need to be redone in the case of the second A, when using createMemo.
5 replies