It’s a big one, modals with Redux and React. In most of our apps, we generally display 2 different kind of modals: simple modals like confirmations, notifications etc. and custom modals like a full fledged login form with validation etc.
Basically these two modules do the same thing: emulate an ES2015 environment but in a different way.
In this article I will explain the difference between these two and when you should use one or the other.
What if you are working on a large project, and after some meetings with your lovely team mates you decided it’s time to sharpen the good ‘ol eslint config.
Everything fails, you got 2042234897234 errors help, 911 please help. WTF.
So you try eslint –fix, but still 999239 errors.
Calm down, I got the perfect solution for you.
What if you could only run Eslint on the commited changed files 😉 ? And by doing so, you can slowly migrate everything to adopt to the new code style. Plus when you have some time left over, you could refactor that auto-fetch-nudes component to the new code style. Fucking awesome.
I have tried many ways for setting up a scalable way to create modals with React and Redux. The approach that I ended up using is basically a tweaked version from a Stackoverflow answer from Dan Abramov’s
Creating modals in React is pretty simple, many solutions implement React Portals but I think rendering a Modal outside of the application container is overkill, we use a ModalRoot container which we render in our application container instead.
So I talk here about a solution that is scalable, testable and simple. It requires some boilerplate code to setup but it’s worth it in the long run.