Image for post
Image for post

Why Redux is not so easy, some alternatives

React with Redux is probably the most popular front-end framework in this year. Redux is great and has changed architecture of front-end apps. If you are looking for new job, you probably will find some interesting offers with Angular 1.x, Angular 2 and others, but most interesting are about React & Redux.

The choice for a lot of programmers is quite obvious, but we should consider some cons of using Redux:

  1. Don’t Repeat Yourself
  2. Care about performance — render()

It’s not easy to switch to work with reducers

You will need to care about functional principles and always return new value based on previous state. Sometimes it’s easy (simple string, objects or array operations) as:

return {…previousObject, newValue: value}

Don’t Repeat Yourself (DRY)

Working with Redux needs to keep some conventions, as create actions types, actions (action creators) and reducers.

Care about performance — render()

In the end what we really want to have is a single source of truth which is easy in maintain, and which trigger smallest changes in DOM structure as possible.

Some alternatives

State management with Redux is predictable but is not easy to learn and not fast to write. There are some alternatives, libraries which make your work much easier:

  1. Relay/Apollo & GraphQL
  2. Jumpsuit
  3. Helpers / generators, as conventional-redux.js

MobX

This new library has a lot of solutions for mentioned problems and I recommend to try it. It is based on 3 points: state, derivations and actions. Thanks to getters and setters synchronization between models and UI is automagic.

Relay/Apollo & GraphQL

Relay & GraphQL stack is not so new, as you could think that it is, but is not so popular as Redux. It is developed by Facebook and described as framework for building data-driven react applications: https://facebook.github.io/relay/.

Jumpsuit

This is a solution for someone, who doesn’t like MobX, but pure Redux is tiresome. Jumpsuit is a framework based on Redux which makes your flow more automatic. If you don’t like to build application from scratch (mean adding & configuring a lot of packages), use Jumpuit, which gives you also simplified API layer for React and Redux.

Conventional-redux.js

One of the biggest problem with Redux app is a lot of code duplications. I have mentioned it in the beginning of this article (Do Not Repeat Yourself). Conventional-redux.js is an interesting approach to simplify your workflow.

Full-stack developer - react.js, node.js, serverless. @machnicki

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store