DEV Community

Discussion on: Opinionated React - Use Status Enums Instead of Booleans

Collapse
 
mxldevs profile image
MxL Devs

The first time I ran into this problem, I switched to using numbers. 0 = not started, 1 = in progress, 2 = ready, 3 = post loading processes, etc.

But then everytime I went back to look at my code a week later I forgot what the numbers meant and it was just a huge pain. Then I found out about enums.

Collapse
 
farazamiruddin profile image
faraz ahmad

I did the same! But like you said, having to remember what all the numbers represented was difficult.

Collapse
 
mxldevs profile image
MxL Devs

I actually tried using constants. NOT_STARTED, LOADING, etc. But enums was still better because of auto-complete and working with interfaces. Taking an enum type as the status is just more descriptive than an int, whether it's written as a constant or otherwise lol