6
My first React app was a mess, then I redid it 6 months later
I built a simple todo app when I first started learning React last January. It worked but the code was this huge tangled thing with state all over the place. I came back to it in July after learning about hooks and context, and rewrote the whole thing in about 200 lines instead of 600. Has anyone else gone back to an old project and been surprised at how much cleaner you can make it?
2 comments
Log in to join the discussion
Log In2 Comments
evan_harris1413d ago
Wait hold on, you rewrote 600 lines into 200? That's insane but I believe it. I had the same thing happen with my first React project from last year, some janky weather app. When I looked back at the code I was using class components and had like 5 different lifecycle methods doing random updates. I had state variables that didn't even do anything anymore. After learning hooks and actually understanding props properly I cut it down to maybe 250 lines and it actually made sense. The crazy part is the old version had bugs I never even noticed until I rewrote it. It's wild how much cleaner things get when you actually know what you're doing.
7
wade43813d ago
I used to be the guy who thought rewriting working code was a waste of time. You know, the whole "if it ain't broke don't fix it" mindset. But your weather app story really hits home for me. I had a similar thing happen with an old e-commerce site I built. I thought it was fine, running okay, no complaints. Then I had to add a feature and realized I had state variables scattered everywhere, some of them just sitting there doing nothing. It was a mess. Once I cleaned it up, not only did the code shrink by more than half, but I also found two bugs that had been hiding for months. I really changed my mind on this one.
2