tableContainerRef is initially null so cannot use tanstack table on first render?
I am using server components to send the initial data to the client immediately. So the very first render of the component should be good to go. However a ref, such as the
tableContainerRef
used in much of the documentation is null on the first render and only an actual ref after the first render, meaning on the first render the table cannot have a body. What is the suggested fix for this?1 Reply
multiple-amethystOP•7mo ago
Hi all, anyone coming back from the future who is stupid like me, here is a solution:
Use a ref callback on the div element and instead of setting a ref, update the state of a ref state variable, this will cause a re-render when the state is updated and allow the table to be used
Use a ref callback on the div element and instead of setting a ref, update the state of a ref state variable, this will cause a re-render when the state is updated and allow the table to be used