I wonder a little about the need, I wonder if you over-simplified your example to not overload the article.
The first call to render will render an empty array as this.state.articles is equal to []. So article.loading will never be used.
Then, when the fetch is done, you have a list of articles assigned to this.state.articles. Before doing that, if you don't display invisible article, I would have filtered the values returned by the server. (by the way, why does the server even return those articles.)
hmmm... Nice writeup but when I look at the original file content:
I wonder a little about the need, I wonder if you over-simplified your example to not overload the article.
The first call to
render
will render an empty array asthis.state.articles
is equal to[]
. Soarticle.loading
will never be used.Then, when the fetch is done, you have a list of articles assigned to
this.state.articles
. Before doing that, if you don't display invisible article, I would have filtered the values returned by the server. (by the way, why does the server even return those articles.)Resulting class would be: