The props are reactive, right?
I've created a small wrapper around
solid-table
:
I use this component within a Suspense
. Therefore props.data is equal to []
, then populated with data. However, it doesn't seem to trigger an update. I tried to use a signal in the middle to make it reactive (see the comments) even if props.data
is already reactive. The effects are triggered and logging the data, but the table remains empty 🤔10 Replies
props are reactive, but you're reading them once in the component body and then that's it. you'll want to do something like this instead
Ow, works like a charm. What should I read to better understand this paradigm?
I feel I missed a step in my understanding of theses cases in the Solid world
Is it common to use this "trick"?
not sure where else to read about it, but yeah it's pretty common
props are (usually) getters and components only run once
so reactivity needs to be triggered through function calls or accessing getters
I'll definitely keep that in mind
thank you 🙏
imo this video is great to get an intuition behind the why https://www.youtube.com/watch?v=cELFZQAMdhQ
SolidJS
YouTube
Intro to SolidJS reactivity (in 5 minutes)
An introduction video that walks you through Solid's reactivity in under 5 minutes.
The guides in docs.solidjs.com are a good intro as well
Yeah I thought I understood all the finesse of Solid while observing and not using. Now that I'm using it actively. I guess I was wrong 😅
I went through the video and this guide:
https://docs.solidjs.com/advanced-concepts/fine-grained-reactivity
Still, it is unclear for me how the getter trick is working in my case
how passing the data via a getter function make it reactive?
does the getter function magically subscribe itself to the signal behing
props.data
?Props is an object that has getters for its dynamic properties:
becomes after transpilation something like
When inside
Component
you access the prop it will call this signal.
you can think of as
If you access a signal outside of an effect it will not be reactive (because there is no effect to be re-run)
That's why
is not reactive as all the signals hidden behind the props are called during initialisation.
While with
we are not accessing/calling the signals during initialisation, but instead passing them straight to createSolidTable
.a very simple playground to explain the main idea: https://playground.solidjs.com/anonymous/3d44bce0-fa6f-4c48-bc0b-5920a3d14977
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
thank you, very clear