Effective Application State Management - Lesson 2

Reading Time: 2 minutes

Prior Lesson

Compose your state

When you are going to introduce an application state you should know how to update it. If you're coming from a pure object oriented language like Java, you might think of a class (maybe using the singleton pattern), which instance(s) keep a list of key-value pairs. This might be sufficient for simple states, but usually you have nested objects, and it could be tedious to control this, as you need to introduce some abstractions and/or (de)serialization mechanism to deal with complex objects.

Continue reading

Using Flux for component states is an anti-pattern!

Reading Time: 5 minutes

Currently, I am refactoring a mid-size application which I started more than a year ago (additionally, to my daily workload). The project is a ReactJS application consisting of more than 120 components already. I started developing without Flux (mainly, due to the fact that I didn't understand the need for Flux initially). In the meanwhile, I gained a deeper knowledge of Flux and decided to go for it in that project. I chose nanoflux as a Flux implementation, my very own implementation. While I think that Flux is - once understood - a very simple concept I discovered that one challenge is to decide what shall be treated by Flux and what not - By far, not everything that is a state is worth being shifted towards Flux.

Continue reading

Lesson Learnt: Isolate Components Behavior in ReactJS

Reading Time: 4 minutes

hangmanA few weeks ago I complained that calling asynchronous operations inside Reacts lifecycle method componentWillMount like AJAX may have collateral effects. In my case, the application hangs and stuck inside an infinite rendering loop. I discovered that my first attempt to solve the problem was by no way the solution, although I thought it was. The real cause was an unfortunate composition of components. The scenario was the following:

Continue reading