|
|
|
|
|
by spion
1207 days ago
|
|
That example makes a lot of sense once you realize how JSX works in SolidJS (and its very different from React): 1. The function is called only once at component construction, and never again. Unlike React, it is _not_ called for every render. 2. Every expression in `{}` is compiled to a thunk function - not to a direct JS expression. For example, the expression <>{props.count * 2}</>
compiles to memo(() => props.count * 2)
Another interesting bit - as the article above rightfully points out, `useState` and `useMemo` are signals. The main difference is that you have to track and specify your dependencies manually, whereas Solid auto-tracks dependencies based on their usage while the computation runs. |
|