Skip to main content

Breaking: EmptyState no longer has a loading prop — show a Spinner while loading

@trackunit/react-components (from 7.0.0) removes the loading prop from EmptyState, with no compatibility shim. If any of your code passes loading to EmptyState, bumping the dependency is a compile failure, not a deprecation warning. Code that uses EmptyState without loading is unaffected.

There is no codemod for this change. Replace each usage by hand as shown below.

Why this changed​

EmptyState with loading rendered a spinner plus a grey pulsing bar standing in for the description. The bar read as a stray line under the spinner, and it stood in for text that only appears if loading ends with nothing to show. An empty state now means one thing: loading has finished and there is no data.

The rule is:

  • While loading, show a Spinner, or a skeleton when the shape of the content is known.
  • Show EmptyState only once loading has finished with nothing to show (no data, an error, not found, no access).

When it affects you​

Nothing changes until you bump the package. At or above @trackunit/react-components 7.0.0, the prop is gone and any EmptyState that passes loading stops compiling until you change it.

// before
<EmptyState description={t("assets.empty")} loading={loading} />

// after
{loading ? <Spinner centering="centered" /> : <EmptyState description={t("assets.empty")} />}

What to do​

  • Pages and sections: render <Spinner centering="centered" /> while loading and EmptyState afterwards, as above.
  • Tables: pass loading to Table and keep the empty state in its emptyState prop without loading. Table shows its own spinner while loading and only renders the empty state afterwards.
  • Loading text: if you passed a description only to show text while loading, either drop it or pass it as the Spinner label.
  • Layout: a spinner is smaller than an empty state. If the surrounding layout jumps when data arrives, give the spinner's container a fixed height with containerClassName.

Spinner now has a default accessible name ("Loading", translated), so a plain spinner is announced by screen readers without any visible text.