Hide React component without unmounting

I ended up coming up with my own solution based on @Diceros answer. Posting for anyone stumbling on this thread.

I added a tabData array to the container state, and then made a saveTabData function which I passed to each component as onLoadData and passed the data itself to the component as well.

In each tab component, instead of calling this.setState to save the data from the fetch, I call the callback this.props.onLoadData to save the data to the containers tabData array. Then I refactored the render methods of each component to get the data from this.props instead of this.state and to simply display “Loading…” when the props data is null (ie. when it hasn’t loaded yet).

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top