The second one is how I used Redux and ultimately realized that I don't need the Connect method. And after removing the Connect method, I had to implement my own re-renders, which I implemented and achieved greater performances. So this is the design tool that I was working on. And this is called BuilderX. And every element that you see on the screen was rendered by React, even the artboards that you see and the smaller elements, like layers and text in there.
So connecting everything to Redux was a bit of an issue, because if you look at the DOM structure or the virtual DOM tree, we have to add Connect method at every location. And this Connect method is executed whenever there is a dispatch, whenever there's a state change, these Connect methods are executed. And the problem here is that I had a lot of elements and all those elements had Connect methods, which was getting called on every mouse move in the design tool. So there were initial optimizations with selectors and those things, but it didn't really work. We removed the Connect methods and we implemented a hook that was the path of the change, and then it just re-rendered that specific thing. We created a hook and whenever there was a change in the entire tree, only listeners of those paths and different components were re-rendering.
Great, and the third one is obviously signals and observability. Signals has been there since the early days of MobX, and that's how Ryan also puts it, React was a signal 10 years later. And there has been a lot of discussions over and over again, from like we called it observability and observer earlier and now we call it signals. So I won't get into the depth of it, but it's being used. If you look at MobX, MobX is being used, even the Blue Sky app that came out, it uses MobX, which is amazing. But as a library maintainer, or if you are building a general purpose library, your philosophies has to stay at the very ground level without adding a lot of complexities. And that's how Dan puts it, that React props and states are raw values. Raw is unsophisticated, and that's the essence. He also says that React will always be a home to those who appreciate them, because raw values, you don't have to create models and wrap your values and do all those things, which is the core principle of React, which is nice that makes perfect sense for a general purpose library like React. But what I want to say is, don't be too burdened by idealism. Know the basics and explore new territories. Something that is generic and widely accepted, it's okay if that does not work for you and you want to do something that is considered as an anti-pattern. Controversial ideas bring new perspectives, keep them coming, and stay kind and humble, learn from each other and build great things. That's me, Sanket.
Comments