Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I tried context as a way for components to read and use the same state without having to throw them around as props. It didn’t work out bc I ended up with re renders that I didn’t want happening (bc components re render when the state they subscribe to changes) and fixing it would’ve required more complex logic. Like if i had component a and b and they’re both subscribed to state c, I would have component a and b rerender when c changes when I only want component a to.
-
RxJs was brought to me before. Does it allow you to prevent unwanted re renders of components that share state? It’s hard to break up components in react and have them use the same data without context or redux, both of which would force re renders when the state is changed. It’s so annoying!
-
@d-fanelli yes. Only components subscribed to an observable will re render. Observables can be in multiple service files
-
@Devnergy thanks. It seems sharing state can be risky business (AT TIMES) bc components re rendering can have unexpected consequences and bugs. Maybe that’s where redux is handy? A Component a can affect component b by dispatching to a reducer and that reducer can return a state that only component b consumes. Redux has been stressing me out for a few days bc it’s been hard to see its point
I don't like React Redux. Big and lots of boilerplate code just to get working. I prefer RxJs and Context API.
But between Context and RxJs, I will choose RxJs for global state management
rant
cause it sucks
i hate redux