| 0 | kirasiris | Website Tags:


I love React but I hate its way to handle state data.

I’m returning two states, posts and profile. Posts checks the database to return data in case something is found and works great; in other hand, I’m calling the Profile state to make sure the user creates a profile before being able to read the fetched data, sounds easy, right? It is not!.

The thing with state management is that you have to create reducers that are going to be loaded after certain action is triggered. This is what makes it possible to show a loading icon while the data is being fetched from the database; a feature that I love.

This should have worked out with no problem at all after creating an if statement such as the following one:

{profile !== null ? (this) : (that)}

The previous line can be read as if profile IS NOT null do/? THIS else/: do THAT. The do THIS is what is not working on my end as you will see in the below .gif file:

State Management
Do you see the ‘create profile’ button for few seconds? Well, that is what I’m having troubles with.

If you guys want to know more about the MERN stack and React itself, read: Post to Myself About MERN

I’m sure this probably has something to do with being inexperienced but hopefully I’ll be able to solve it in few more days.

Leave a Reply

Back to Top