Almost every UI app I've seen has an isLoading
boolean somewhere in the code. And if it's not that, it's some variation of a boolean that's intended to represent some state. Unfortunately, very often this leads to states that exist in the real world that are unrepresentable in the code, or states in the code that are impossible in the real world. In either case, you've got yourself a bug.
From this lesson you'll learn how to avoid this by using a status
enum instead of an isLoading
boolean in a React custom hook for retrieving the user's position via the geolocation API.
This is based on my blog post: Stop using isLoading booleans.