SolidTable infinite loop with `createAsync` query, createMemo but not createSignal + createEffect?
I'm writing a SolidStart project, using SolidTable to display data from a backend DB. I'm using SolidStart
query
to fetch data and SolidStart actions
to insert data. I'm running into an issue where if I supply the createAsync
accessor of the query directly as the data
parameter for the table - it hangs / hits out of memory errors when I insert a row using the action
. I'm not 100% sure what causes the issue but it seems like it might be an infinite re-render of the table. If I keep everything the same but change the table data to be an empty array then it works no problems - so not an issue with the DB/query/action by themselves, it's only when its used as data for the table.
I've tried some alternative approaches - createMemo
of the createAsync
accessor does not work - but strangely if I use createSignal
and then update it with the value of the createAsync
query in createEffect
then it does work? Why createSignal/createEffect here work when createAsync does not? Does createAsync not have stable references?
Please help me work this out - I'd really like to not use createEffect to make this work if I can avoid it. Thanks!
3 Replies
You may have a look at this code. Simplifies a lot.
If you call the async accessor inside the createEffect the Suspense boundary in a higher up component will be triggered. I would generally avoid that. If you need to make computations on the client you can do:
Not sure what causes the infinite loop on the Datatable component.
Thanks! lots of good trips in your response 🙂
Oh and what I'd always recommend with Tanstack table is to seperate data fetching to a higher component because with the
createSolidTable
you are accessing the data accessor outside of the JSX so the Suspense
inside this component does not pick this up and you'll fallback to higher up Suspense
boundary.