Next.js Discord

Discord Forum

data to a client component and server component

Unanswered
Himalayan posted this in #help-forum
Open in Discord
HimalayanOP
Hi there,

I am trying to create a tanstack table where the amount of columns is unknown (the type is known) as they contain data grouped into months and years, for example could be Jan 21, Feb 21 Mar 21 or could be Feb 22, Mar 22, Apr 22, May 22 etc depending on the data fetched from the api. My problem is how to get this data to the columns definitions which need to be client side?

Currently the setup is:

Serverside tsx page
Importing tanstack datatable (client component)
Importing columns definitions (client side and needs the data to determine columns)

fetching data ()

Return
Datatable where data=data and columns =columns.

Any ideas? Should I just do a use effect in the columns file and fetch the data again via a route handler?, just seems wrong to me.

0 Replies