How to add spinner React Js and Bootstrap

I am using bootstrap datatable [not the reactjs datatable] and reactjs and mongoose
i want to display spinner till data is loaded in the page

Traditionally, you would have some way to know if the data is loading - maybe your have a flag like “isLoading” or you just have the data be null until it is loaded. Then you could do a return early:

  // ...
  if (isLoading) {
    return <Spinner />
  return (
    // the rest of the stuff I want normally

You could also have that logic in your JSX, using ternary operators and/or short circuit ANDs (&&). Or some people bury that logic in an HOC or a container component.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.