Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make loading animation with react-bootstrap

I want to make a loading animation with react-bootstrap, while waiting for an API call. I know how I should set the state to start and stop it, I just don't know how to do it with react-bootstrap. I guess I have to use an Overlay (for the "fade" effect) and a Spinner, but not sure how.

Thank you!

like image 697
Alexandre Serra Avatar asked Apr 19 '20 22:04

Alexandre Serra


1 Answers

You can achieve it in many ways. One very simple is with conditional rendering: where loading is your state while you are fetching...

{loading?<YourComponent/>:<Spinner animation="border" role="status">
  <span className="sr-only">Loading...</span>
</Spinner>}

like image 196
Javier Alejandro Avatar answered Oct 13 '22 00:10

Javier Alejandro