I have a list with items that first loads 30 items and if the user clicks on "Load All", rest of the items are shown:
+---------------------------------------------------------+
| |
| List |
| |
| |
| |
+---------------------------------------------------------+
| Load All Button |
+---------------------------------------------------------+
When the list is big (more than 1K items) the rendering of the "Load All" step takes some time and meanwhile the DOM is stuck and not responsive.
What is the right way to tap into React's lifecycle events so that upon clicking the button it will change to a loading spinner and when the list is fully rendered and ready it will change back ?
I have tried separating the two parts (list and button) to two components and wrap them in a parent component that holds a "loading" and then changing the state in the List componentDidUpdate
function, but it didn't work