DEV Community

George Jowitt
George Jowitt

Posted on

1

Redux - a persistent question

This article was originally posted here.

Redux is a predictable state container for JavaScript apps. - redux.js.org

As a relative newcomer to all things web development, I came across Redux mere seconds after I started using React.

After what I would say is a fairly steep learning curve, having only just been introduced to state and props, I slowly but surely began to understand how to use Redux, and why it is such a useful weapon when developing web apps.

And that is where my troubles started, I fell into a Redux quicksand of sorts. Every new component I created had its own Redux store. Every single API call had at least one Redux action, and I was forever calling 'SetCurrentUser', or 'ClearCurrentUser' actions just to keep track of things!

Just because you can, doesn't mean you should

I had built multiple redux stores, all with the same functionality for slightly different components, my redux folder was becoming bloated, and sure, my component files were nice and slimline, but at what cost.

So now when I create a new component, and I reason as to whether to Reduxify it, I as myself the following:

Do I need the data from the page to persist when I navigate away? Or can I just make the call again when I come back to the page?

More often than not, the answer (to the first part of the question!) is no! And I can just use the components state to handle the data.

I now use Redux for things like Auth, and Permissions, bits of data that I need in more than one place.

This is a massive oversimplification of a complex topic and there are many great articles out there about it, but this is my hot take and a great place to start.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay