DEV Community

Discussion on: Redux Hooks!

 
leob profile image
leob

Haha but I sent you the wrong article! That article from Eric Elliot is more a grab bag of ideas and he doesn't do an in-depth comparison of Connect vs the Redux hooks ... I was confused, and the article I really meant is this one:

itnext.io/how-existing-redux-patte...

This article goes into great depth comparing the performance of Connect with the Redux hooks in various scenarios.

It all revolves around the overhead of causing unnecessary re-renders, and he shows how to "measure" that. And, what he claims is that Connect is doing automatic 'referential caching', which would also be possible with the hooks but it's not "built in".

In his summary titled So should I start using the Redux Hooks? he says that:

"When you move away from connect you lose a lot of the performance benefits it provides ... this means that you’ll have to be more cautious when considering re-renders"

But to determine if this claim is justified (and what it means) you'll have to read the rest of the article.

You can read Eric Elliott's article if you like, however the one I meant was in fact this one!

Thread Thread
 
leob profile image
leob

P.S. so you think he has a point that Connect still has potential advantages with its "baked in intelligence" to prevent re-renders?

Thread Thread
 
jimmymcbride profile image
Jimmy McBride

You can do it all on your own, which does defeat the purpose of connect doing it for you. Although, the fixes to get same preformances aren't difficult, and those fixes would make other things in your app more preformant. So there's that.

Unless you're REALLY into getting optimal preformance, I don't think the rerenders you loose out on are going to really slow your app down.

I think if it comes down to improving your rerenders your going to use useMemo anyways.

Thread Thread
 
leob profile image
leob

Right, so if you grasp how it works then without too much difficulty you can obtain virtually the same performance, and you're learning something useful in the process (you'd gain a deeper understanding) ... if I'd ever attempt this stuff then I'd re-read that article first!

Thread Thread
 
jimmymcbride profile image
Jimmy McBride

Definitely. useMemo is a great hook to learn too. If your into rerender optimization, check out React hook from. It does some pretty cool stuff!

Thread Thread
 
leob profile image
leob

Ah you mean React Hook Form? react-hook-form.com/

Thread Thread
 
jimmymcbride profile image
Jimmy McBride

Oh, yeah!