My inspiration on WHY to use it

Approximately 12 months ago, I started writing the first draft of the structure I wanted to use at Askable. Based on my previous experiences, I was tempted to use React and Redux. React sounded like an obvious choice, but Redux didn’t.

Don’t get me wrong, Redux is an amazing tool. However, I always felt I had to code way too much to achieve what I wanted. Writing actions, reducers, connectors and so on wasn’t an easy task (Specially if you have a nested-structured state).

Finally, I decided not to use Redux and check some alternatives as I wanted to deliver features fast.

The Problem

Finding an easy way to use common component in different files without having to import them into each of them was the main problem I faced.

For instance, you have a component called Header.js and want to call a modal component called modalPricing.js . It’s not a big problem to include the modalPricing.js file straight into your Header.js . However, what if you need to call the same file into your Footer.js ? Would you import the same file? And what if you have to call the same modal somewhere else?

If you adopt this solution you will end up with multiple instances of the same modal window into your DOM. As you probably know, that’s not a good practice.

The Solution

I could just use a Redux Provider and pass down props to open/close the modal when I want to. However, as I mentioned before, I didn’t want to go down this path. Besides, I didn’t want to include another dependency on my project.

That’s main the reason why I was stoked when I saw that the React team was planning to support the Context API out-of-the-box. This would, in theory, solve my problems.

I then decided to use the “Just do it” methodology :)