T
TanStack•3y ago
metropolitan-bronze

Async accessorFn

I ran into a situation where I felt like I needed an async accessorFn. It seems like this isn't supported. Has anyone else run into this type of thing?
5 Replies
other-emerald
other-emerald•2y ago
i'm trying something similar where i want to call a server action for a cell but this does not seem to support async. this is what i'm trying:
cell: async ({ row }) => {
"use server";

return await generateActionColumn(row);
},
cell: async ({ row }) => {
"use server";

return await generateActionColumn(row);
},
but i get the following error: Cannot destructure property 'row' of 'undefined' as it is undefined.
evolutionary-blush
evolutionary-blush•2y ago
Any chance you could return an unawaited promise from the cell fn, then await it in your component? Without knowing the specific use case, it's hard to say that this is a good idea though 😬.
other-emerald
other-emerald•2y ago
not really. i'm trying to make my Columns: ColumnDef function to be a server component so it can't have callouts to functions.
evolutionary-blush
evolutionary-blush•2y ago
Won't this mean there's a network/io request of some kind for each of these cells?
other-emerald
other-emerald•2y ago
nah, i'm just wanting to pass the row

Did you find this page helpful?