I love coding and what motivates me is problem-solving and preferably if it has an element of creativity.
I am a self-taught developer and work full-time as a front-end developer.
Location
Denmark 🇩🇰
Education
Bachelor in Nutrition and health (I know not super relevant to my current line of work!)
{!!isLoading ?
(<div>Data is Loading</div>)
:
(!!isError?
(<div>Something went wrong</div>)
:
(<div>Data</div>)
)}
My point is that the booleans make it possible to use really short syntax.
I definitely see your point when status could have a lot of different states, but if you have a lot of different skeleton loaders and stuff I think booleans are hard to beat.
why not return the different states like booleans?
something along the lines:
const [iddle, resolved, rejected] = GetData(URL)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It might be great for some situations but more verbose for others...
Let me explain.
Normally (in React, but I guess it would be almost the same elsewhere) I would import the fetch logic like this:
const [isLoading, Data, isError, Error] = GetData(URL)
Then in the JSX:
My point is that the booleans make it possible to use really short syntax.
I definitely see your point when status could have a lot of different states, but if you have a lot of different skeleton loaders and stuff I think booleans are hard to beat.
why not return the different states like booleans?
something along the lines: