DEV Community

Cover image for "From Clueless to Clicks: My Hilarious First Steps with React"
Aryam Michel
Aryam Michel

Posted on

"From Clueless to Clicks: My Hilarious First Steps with React"

Let me set the stage: it’s a quiet Tuesday night, and I’ve decided to dip my toes into the vast, occasionally terrifying, waters of front-end development. My weapon of choice? React. Why? Because everyone is raving about it. Spoiler alert: they were right, but also, wow, the rabbit hole is deep.

If you’re a beginner, buckle up; here’s my story (and some tips) about how I survived my first encounter with React, guided by the CodewithMosh course—a true beacon in my coding journey for this particular project.

Step 1: How Vite Made Me Feel Like a Pro

Forget the intimidating sea of files from create-react-app. I took the cooler, sleeker route: npm create vite@latest. Why Vite? Because it’s fast, modern, and everyone online swore by it like it was React's hip younger sibling.

When I ran the command, Vite asked me a few friendly questions—like what framework I wanted (React, obviously)—and before I knew it, I had a project structure that felt lean and purposeful. No unnecessary files to overwhelm me. It was like walking into a perfectly organized closet where everything had a place.

Pro tip: Vite doesn’t just set up your project; it makes you look like you know what you’re doing. The built-in dev server is lightning fast, and I was up and running in seconds. I stared at my new app in the browser, complete with a rotating Vite logo, and thought, "Look at me, living the future."

Step 2: Writing HTML-ish JavaScript (What Is This Sorcery?)

When I started typing what looked like HTML into my JavaScript file, I half-expected my code editor to yell at me. But nope, it was all smooth sailing. Turns out, this magical syntax is called JSX—short for JavaScript XML—but you won’t see it labeled as such anywhere in your project. It’s just there, like a quiet genius making everything work.

JSX lets you mix JavaScript with HTML-like syntax, which felt weird at first. But then I realized it’s like ordering a combo meal—two favorites combined into one convenient package. Want to loop through an array and create a list of <li> elements? JSX makes it ridiculously easy.

Pro tip: Embrace the weirdness. JSX might not look like traditional JavaScript, but once you see how dynamic your UI becomes, you’ll be hooked. Just don’t forget the golden rule: wrap everything in a single parent element. React is picky like that.

Step 3: Components – The Building Blocks of React (and My Sanity)

Think of React components as tiny, reusable Lego blocks. Each block does one job, and together, they build something awesome—like your app! My first component? A humble button that proudly said, “Click Me.”

Thanks to Mosh’s course, I learned a golden React rule: Components are like your favorite snacks—shareable and reusable. Want a header on every page? Wrap it up in a component. Need 20 buttons with slightly different labels? Boom, one button component and some props (don’t worry, I’ll get to those next).

Pro tip: Keep your code DRY (Don’t Repeat Yourself). The more you reuse components, the easier your life becomes. Trust me, your future self will thank you when you’re not digging through 15 files trying to change a single button style.

Step 4: Props – The Secret Sauce of Customization

Props are like the toppings on your React pizza—they let you customize each slice (or component). For example, I could pass a label="Submit" prop to my button component and suddenly, it had personality.

I can’t imagine React without props. They’re what make components dynamic and reusable. It’s like giving each Lego block its own unique flair.

Step 5: State – When React Gets Real

State is what gives React its magic. It’s how your app becomes interactive, like updating a counter or toggling a dark mode button. The first time I watched my app re-render in real-time, I felt like I’d unlocked a superpower.

But let me tell you, state management is also where things can get... tricky. Forget to use setState, and you’re stuck wondering why nothing is updating. Update state carelessly, and your app might start throwing a tantrum.

Mosh’s advice stuck with me: Keep your state as simple as possible. It’s tempting to throw everything in state, but trust me, less is more.

Why You Should Start React-ing!

  • React isn’t scary. It’s weird at first, sure, but once you understand the basics, you’ll see why everyone loves it.

  • Vite is a game-changer. If you’re just starting, do yourself a favor and skip the bloated setups. Vite is your friend.

  • Celebrate the small wins. Every time I got something to work, no matter how small, I felt like a coding ninja. Debugging, though? That’s another story.

Top comments (0)