DEV Community

Discussion on: When a simple React context gets out of hand.

Collapse
 
alexandrricov profile image
Alex • Edited

Usually, not needed to make posts and comments related state global (not needed to move it to context), only in case it used in multiple pages. Also, there are no sense to keep isLoggedIn as separate state because it could be calculated from other values, in present example:

<AuthContext.Provider value={{ state: {
user,
isLoggedIn: !!user,
}, setUser }}

I switched from redux to react context few years ago, and I write now less template code. And yes, I miss a good extension for state inspection, like redux chrome extension

Collapse
 
basicbrogrammer profile image
Jeremy Ward šŸ˜ŽšŸ¤“

Hahaha yeah I thought about the isLoggedIn state as I was writing the post šŸ¤£ I was trying to come up with an abstract idea bc I couldn't just copy paste our code from work šŸ™ƒ

What do you do without the redux dev tool?

I found this but haven't tried it out yet github.com/troch/reinspect

Collapse
 
alexandrricov profile image
Alex

Without redux devtools Iā€™m crying :ā€™(
Lol just kidding, I can check context state in react devtools components tree.
I missed to mention: good job and really descriptive article!

Thread Thread
 
basicbrogrammer profile image
Jeremy Ward šŸ˜ŽšŸ¤“

Thanks! That's what I've been doing too but I miss the dispatch call stack :(