Skip to content

Display skeleton rows during initial load #2386

Discussion options

You must be logged in to vote

Hi,

Recently I had added Skeleton loading to my table. First I attempted what you're doing but I quickly went ahead with other approach.

The idea is to change the data & columns array passed to useTable if the content is loading. The following code create 30 rows (you can change according to your requirement) with empty data, and replace each cell with Skeleton component.
The good thing is your column headers/footers are intact.

const Table = (columns, data) => {
  ...
  const tableData = React.useMemo(
    () => (loading ? Array(30).fill({}) : data),
    [loading, data]
  ); 
  const tableColumns = React.useMemo(
    () =>
      loading
        ? columns.map((column) => ({
            ...c…

Replies: 2 comments 16 replies

Comment options

You must be logged in to vote
14 replies
@Skia69
Comment options

@jslyonnais
Comment options

@jsaunders92
Comment options

@mbyrne00
Comment options

@JulienLemaitre
Comment options

Answer selected by taschetto
Comment options

You must be logged in to vote
2 replies
@dmitry-mitrakhovich
Comment options

@dmnlgn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet