SIGN IN

Kirill Novik's Account

Kirill Novik offline long ago

React Hooks + RxJS or How React Is Meant to Be

0

Great point! So, technically I would use either of these approaches to prevent unnecessary rerenders: 1. Split state in separate BehaviorSubjects or 2. Pipe your subject through filter like: useSharedState(subject.pipe(filter(s => s.type === 'test'))) // Let's say your state looks like { type: 'type', content: 'content' }

React Hooks + RxJS or How React Is Meant to Be

0

First off, thanks a lot for your comment! I actually would like to challenge your point about the state modification. BehaviorSubject is more like an action/reducer combo, not the whole state. Remeber, that I argue in the article that we use combineLatest to get the whole state. To enable time traveling, we could use either ReplaySubject that can keep a reference of BehaviorSubject and a value the subject is being assigned, so it is essentially the same functionality as Redux and just a couple of lines of code. You can write your own HOCs too. I personally don't mock my shared state, I just set it the way I want. Not sure I understand the problem you're having with TypeScript, though. I really would encourage everyone looking at this to try this approach and to write a small app to really get to feel it. Here is a starter that you might have already looked at: https://codesandbox.io/s/how-react-should-be-50wp0

React Hooks + RxJS or How React Is Meant to Be

0

I agree, it can be very difficult to debug. But the beauty of rxjs is that it gives you choices. Instead of composing streams you can turn your observable into a promise and do the imperative programming that is easier to debug.

Building React Components Using Children Props and Context API

0

Great stuff, very useful pattern! But I think the title of the article is misleading, I think it should explicitly mention "Containment pattern" in the title.

Sign in

Forgot password?

Or use a social network account

 

By Signing In \ Signing Up, you agree to our privacy policy

Password recovery

You can also try to

Or use a social network account

 

By Signing In \ Signing Up, you agree to our privacy policy