React is the Treasure I Found Among The Goats

Max Antonucci - Feb 20 '18 - - Dev Community

Like many devs, I imagine my first response to React was dismissal.

  • It's just another JavaScript trend that'll fade out fast
  • Writing HTML in the JavaScript is asinine
  • I'll never tire of jQuery
  • I'll totally get to bed early tonight.

Turns out I was wrong on all counts, and began changing my mind after doing actual research. One recent article in particular gave some surprising statistics. React growth has outpaced other JavaScript frameworks, and at this rate will overtake Angular usage. It's won in user satisfaction, including against Vue. React beat jQuery in indeed.com job listing popularity, its first loss in over a decade.

So I swallowed my pride, donned my learning cap, and dug into React. I read through the docs, read articles breaking down the pros and cons, and did some tutorials. But my final test was my JavaScript rite of passage - using it to recreate the famous Monty Hall Dilemma. I did the same when learning jQuery, Angular, and Vue. Now it was React's turn.

The result? React passed with flying colors, and broke through my last layers of cynicism. Check out the final result and the code repo.

This post actually isn't about how I coded this app - I don't think there's enough interesting tricks to justify a full post. Instead, it's about how my opinion of React changed as I made it.

Wait, Why the Monty Hall Dilemma?

If you haven't heard of it before, the Monty Hall Dilemma (MHD) is a well-known little logic puzzle. You're given three doors, one with treasure and two with goats. You select one door, but before that door is revealed, the host opens a different door that has a goat. You now have a choice: stick with the unopened door you chose, or switch to the other unopened door. Statistically, you double your chances to win by switching.

I've found the MHD hits the sweet spot for learning a tool or framework. It's simple enough for a relative beginner to handle, but complex enough to solve creatively and overcome common issues in serious projects. Most importantly, by the end I know if I'm comfortable with the new tool or not.

Lastly, it allows me to make intriguing, click-baity blog post titles like the one here. Isn't that what matters most in the end?

Why did React do so Well?

This is a tough question to answer, since my reasons for liking React cover a wide spectrum. Most have already been discussed in any number of React articles:

  • React components and their styles are extremely modular, which fits well with my preferences for object-oriented coding and atomic design.
  • React's virtual rendering engine lets it be used beyond the web, such as for mobile apps and virtual reality.
  • The above virtual rendering engine, combined with one-way data-binding and conditional rendering, makes React very fast. Who doesn't love fast apps?
  • CSS Modules. Enough said.

But the main reason I'm liking React will seem counter-intuitive: there's no "framework magic."

With React, You Need the Fundamentals

You may wonder why "needing more work" is a plus. Frameworks I've used, like Ember and Rails, do lots of work for devs with the "convention over configuration" mindset. I'm not against this, especially for more experienced developers who need to start and scale an app fast - it saves times and gets things going. React also has "Create React App" that makes a basic, preconfigured React project, so it's not above this either.

But at its core, React is a library, not a framework - it doesn't have that magic. Even with Create React App, I couldn't ignore basic JavaScript - functions, ES6, scope, closure, imports and exports, destructuring, etc. I can't ignore how the app works, how it's structured, or where the data comes from. I'll also only write better React by writing better JavaScript as a whole, which is ultimately what I want.

This matters to me, since using a tool based on better fundamentals helps me learn as a junior dev and keeps away Imposter Syndrome. React doesn't demand understanding much about the library itself, but it does demand a strong knowledge of JavaScript. This greater learning curve for beginners is why I've put off React for so long, but I think I misunderstood it. That curve comes from more learning the language, not the library. That's a curve I'm all the more eager to get over, and I'll take every incentive I can to beat it.

React will be great to play with as I build this foundational knowledge. It may be limited to side projects for several years, but even so, I'll keep using it. I already have several ideas, including using Gatsby.js to remake my personal site for the May 1st Reboot challenge.

Normally I don't learn this much from a game about looking for treasure among the goats. Never would've guessed the "treasure" here was a new favorite JavaScript library!

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player