So the large hype on React Hooks is over and the community isn't talking about them that much anymore. But seriously hooks are beasts. In this post...
For further actions, you may consider blocking this person and/or reporting abuse
I had recently implemented something similar to this.
I did the same thing, initializing
loading
state tofalse
. However, my coworkers argued that it could bebecause the Hook will eventually set
loading
state totrue
any way. I argued that the Hook isn't actually fetching until the effect runs, which is why I initializedloading
state tofalse
. I eventually gave in and initializedloading
state totrue
because I felt like we were bikeshedding.Anyway, what do you think?
Eventually found one good thing about initializing
loading
state totrue
. If the component using this custom fetch Hook rendered some other content, it won't flicker. In your case, this shouldn't happen though since BookList isn't rendering anything other than the fetched books.That's true! I'll update the post and add your note to it.
How do you deal with this part:
This causes annoying flashing, before promise is resolved. Is there a way to show this loader inside actual markup, instead of this single element with Loading...?
Loved your explanation. Can you describe useEffect in detail in next post. I couldn't understand the use case
Hey, thank you a lot.
I won't write about useEffect in the next post but I just wrote a quick explanation here:
dev.to/bdbch/a-quick-explanation-o...
Let me know if it helped you! :)
Nice Article...
useful info, remarkable clarity, one small typo (closing paren):
Thank you very much! Fixed!
I'd say because of the comments which are cluttering the actual source code and the new way to update states etc.
This code is subject to race conditions. Check my post about that subject here: dev.to/sebastienlorber/handling-ap...
what would be the pros and cons on using fetch vs axios ?