# State management - more than 'isLoaded'

## Basic flags

You can start making (not only) React’s async state management with flags.

Let’s assume you want to load data from backend to your React app. You would want to show placeholders when data is not fetched. What’s the simplest way?

const Component = ({isLoaded, data, ...otherProps}) => {
return <Placeholder/>;
}

}


Convenient?

Yeah. For simplest use cases. What should you do when you need additional state - during load?

Stuff gets more complicated; less maintainable:

const Component = ({isLoading, isLoaded, data, ...otherProps}) => {
return <ProgressBar/>;
}

return <Placeholder/>;
}

}


What if you need more states like this?

Component’s code will get messy in a blink of an eye. Each time you want to introduce new component state, additional flag would have to be introduced.

Convenient? Not at all!

So, how to make it better?

## Enum for the rescue

Our white knight here could be enum. More maintainable, takes less memory.

How so? Let’s look at the next example:

 const STATE = {
INITIAL: () => <Placeholder/>,
ERROR: () => <ErrorComponent/>,
};