React JS Unpacked: Your First Steps in Web Development (Day 1 of 30)

By Mindwriter AI

Updated On:

Laptop screen showing React JS code editor with "Hello, World!" text and React logo, symbolizing the start of a coding journey.

Join WhatsApp

Join Now

Hey there, aspiring web wizards! Ready to kick off your coding adventure? Today, we’re taking our first exciting step into building amazing websites with something called React JS. It’s like having a magic toolbox to create interactive and beautiful web pages.

Why React JS is So Amazing (The Benefits!)

 

Before we even dive into what React JS is, let’s talk about why so many developers love it and why it’s such a fantastic choice for your web development journey. Think of these as its superpowers!

  • Build Faster with Reusable Pieces (Components!): Remember our LEGO analogy? React encourages you to build small, independent pieces (components) that you can use over and over again. This is like having a perfectly organized LEGO bin – you don’t have to build a new wheel every time you want to build a new car! This saves a ton of time and makes your code super organized.
  • Super Fast Websites (Thanks, Virtual DOM!): React uses something clever called a “Virtual DOM.” Imagine your website is a huge book. Instead of rewriting the entire book every time you change one word, React first makes a quick, invisible copy (the Virtual DOM), figures out only what changed, and then updates just those tiny changes on your actual website. This makes your websites feel incredibly fast and smooth for users.
  • Huge Community & Loads of Help: React has a massive community of developers all around the world. This means if you ever get stuck (and you will, that’s part of learning!), there are tons of tutorials, forums, and friendly people ready to help. You’ll never feel alone on your coding journey!
  • High Demand in the Job Market: Simply put, companies love React. Learning React JS opens up a lot of doors to exciting job opportunities in web development. It’s a skill that’s highly sought after!
  • “Learn Once, Write Anywhere”: While we’re focusing on web here, the concepts you learn in React JS can even be used to build mobile apps (with something called React Native!). So, your skills can travel!

Now that you know why React is so powerful, let’s see what it is and how we use it!

 

So, What Exactly is React JS?

 

Imagine you’re building a LEGO castle. Instead of building the whole castle from one giant brick, you build small, individual pieces like walls, towers, and roofs. Then, you snap these pieces together to create your magnificent castle.

React JS is very similar! It’s a special JavaScript library (think of it as a collection of ready-made code) that helps us build complex web pages by breaking them down into small, reusable pieces called components. Think of each component as a LEGO brick. You build a “button” component, a “navigation bar” component, or a “product card” component, and then you put them all together to make your website.

Why is this so cool?

  • Easy to manage: If something goes wrong with a small brick, you fix that brick, not the whole castle!
  • Faster to build: You can reuse your bricks over and over again. Need another button? Just use your button component!
  • Super fast websites: React makes your websites feel snappy and quick for visitors.

 

Getting Your Computer Ready for React JS (The Setup)

 

Before we start coding, we need to get our digital workshop ready. Don’t worry, it’s not as scary as it sounds!

Step 1: Install Node.js

Node.js is like the engine that powers our React projects. It allows your computer to understand and run JavaScript code outside of a web browser.

  • How to get it: Go to the official Node.js website: https://nodejs.org/en/
  • Which one to pick? You’ll see two download options. Always choose the LTS (Long Term Support) version. It’s the most stable and recommended for most users.
  • Installation: Just download and double-click the installer. Follow the on-screen instructions, mostly clicking “Next” and “Accept.” It’s like installing any other program!

(Image Placeholder: Screenshot of the Node.js download page with LTS version highlighted.)

How to check if it’s installed? Open your computer’s terminal or command prompt (search for “cmd” on Windows or “terminal” on Mac/Linux). Type:

Bash

node -v

and press Enter. You should see a version number like v18.x.x. If you do, congrats! Node.js is installed.

Step 2: Install a Code Editor (Our Coding Notepad)

You’ll need a place to write your code. Think of it as a fancy notepad made specifically for coding. My top recommendation is VS Code (Visual Studio Code). It’s free, powerful, and very popular among developers.

  • How to get it: Go to https://code.visualstudio.com/
  • Download and Install: Just like Node.js, download the version for your operating system and follow the installation steps.

 

VS Code download page showing the "Download for Windows" button.
Download VS Code here – your essential coding companion!

 

 

 


 

Your First React App: “Hello, Vite + React!”

 

Alright, workshop’s ready! Let’s build our very first React application using the super-fast Vite tool.

Step 1: Create Your Project with Vite

Open your terminal or command prompt again. Navigate to a folder where you want to keep your projects (e.g., cd Documents/ReactProjects).

Now, type this magical command:

Bash

npm create vite@latest

Press Enter. You’ll then be asked a few questions in your terminal. Follow these prompts:

  • Project name: Type my-first-react-app (or any name you like) and press Enter.
  • Select a framework: Use your arrow keys to select React and press Enter.
  • Select a variant: Use your arrow keys to select JavaScript (unless you want to learn TypeScript right away, which is totally fine, but we’ll stick to JS for this challenge) and press Enter.

Vite will then quickly set up a new project for you! It’s much faster than older tools.

(Image Placeholder: Screenshot of the terminal showing npm create vite@latest commands and selections.)

Step 2: Go Inside Your Project & Install Dependencies

Once Vite finishes, you’ll see instructions in your terminal. You need to go into your new project folder and install some necessary files (dependencies):

Bash

cd my-first-react-app
npm install

The npm install command might take a few moments. This downloads all the small pieces of code your new React project needs to run.

Step 3: Start Your React App

Now for the exciting part! Type this command:

Bash

npm run dev

Press Enter. Your browser should automatically open a new tab, usually at http://localhost:5173/ (the port number might vary), and you’ll see the default Vite + React welcome page! You just ran your first modern React application! How cool is that?

 

Browser displaying the default React JS welcome page with the React logo and "You are running React" text.
This is what you’ll see in your browser after running npm run dev.

 

 

Step 4: Let’s Edit Our First Code!

Now, let’s make it say “Hello, World!”

  1. Open your project in VS Code: In your terminal (while still inside the my-first-react-app folder), type:

    Bash

    code .
    

    (that’s code followed by a space and a dot) and press Enter. This will open your entire project in VS Code.

  2. Find App.jsx (or App.js): In the left sidebar of VS Code, you’ll see a list of files and folders. Go to the src folder, and then click on App.jsx (Vite often uses .jsx by default, but if you have App.js, that’s fine too!). This is one of the main files where we’ll write our code.
  3. Make your change: When you open App.jsx, you’ll see some code that looks a bit like this (the original default content for a Vite + React app):

    JavaScript

    import { useState } from 'react'
    import reactLogo from './assets/react.svg'
    import viteLogo from '/vite.svg'
    import './App.css'
    
    function App() {
      const [count, setCount] = useState(0)
    
      return (
        <>
          <div>
            <a href="https://vitejs.dev" target="_blank">
              <img src={viteLogo} className="logo" alt="Vite logo" />
            </a>
            <a href="https://react.dev" target="_blank">
              <img src={reactLogo} className="logo react" alt="React logo" />
            </a>
          </div>
          <h1>Vite + React</h1>
          <div className="card">
            <button onClick={() => setCount((count) => count + 1)}>
              count is {count}
            </button>
            <p>
              Edit <code>src/App.jsx</code> and save to test HMR
            </p>
          </div>
          <p className="read-the-docs">
            Click on the Vite and React logos to learn more
          </p>
        </>
      )
    }
    
    export default App
    

    We’re going to simplify this a bit for our “Hello, World!” by changing the <h1> tag and removing the count state and the button.

    Here’s what your App.jsx file should look like after this small but impactful change:

    JavaScript

    import './App.css' // Keep your CSS import
    
    function App() {
      return (
        <>
          <h1>Hello, World! Welcome to Day 1 of our MERN Stack Challenge!</h1>
          <p>
            You're now building with Vite and React!
          </p>
        </>
      )
    }
    
    export default App
    
  4. Save your file: Press Ctrl + S (Windows) or Cmd + S (Mac).
  5. See the magic! Go back to your web browser. Without even refreshing, you’ll see your text has changed instantly! This is one of React’s superpowers, enhanced by Vite’s blazing-fast Hot Module Replacement (HMR) – it updates your website instantly as you code.

 

 

 

VS Code editor displaying App.jsx file of a React Vite project, with the tag changed to "Hello, World! Welcome to Day 1 of our MERN Stack Challenge!" highlighted.
Editing Your First React Code with Vite

 

Browser Screen Showing "Hello, World!" Change (Vite Project)
Your “Hello, World!” message live in the browser, instantly updated by Vite’s magic!

 

Understanding React JS Components (Our LEGO Bricks)

 

Remember our LEGO analogy? In React, those LEGO bricks are called components.

Look at the App.jsx (or App.js) file again. You’ll see this part (this is the basic structure of a functional component in React):

JavaScript

import './App.css'

function App() {
  return (
    <>
      {/* ... your JSX code here ... */}
    </>
  )
}

export default App

This App is a component.

  • It’s a JavaScript function (that’s what function App() { ... } means).
  • It returns something that looks like HTML (that’s the stuff inside return (...)). This mix of JavaScript and HTML is called JSX (JavaScript XML). Don’t worry, it’s just a convenient way to write HTML-like code directly in your JavaScript files.
  • export default App; means this component can be used in other parts of our application.

Every piece of your React website, from a simple button to an entire section, can be a component. We combine these small, focused components to build a large, complex application.


 

Common Mistakes Beginners Make (And How to Avoid Them!)

 

It’s totally normal to make mistakes when you’re learning something new. Here are some common ones with React and Vite:

  1. Forgetting to install Node.js: React needs Node.js to run. Always check if it’s installed correctly (node -v). If you ran into issues, check out our guide on Troubleshooting Node.js Installation Issues (example internal link).
  2. Typos in commands: npm create vite@latest instead of npm crete vite@latest or npm run dev instead of npm run deve. Double-check your spelling!
  3. Not running npm install: After creating a new Vite project, you must run npm install to download all the necessary project dependencies before running npm run dev. This is a common step beginners miss.
  4. Not changing directories: After creating your app, you must go into its folder using cd my-first-react-app before running npm install or npm run dev.
  5. Editing the wrong file: Make sure you’re editing src/App.jsx (or App.js) when we do our “Hello, World!” example, not some other random file.
  6. Not saving your changes: If you change code but don’t save the file (Ctrl + S or Cmd + S), your browser won’t update.
  7. Confusing className with class: In regular HTML, you use class="my-style". In React’s JSX, because class is a special word in JavaScript, we use className="my-style" instead. React will automatically convert this to class in the final HTML. For more on JSX, read our post on Understanding JSX: JavaScript XML for React (example internal link).
  8. Forgetting to export default: If you create a component but don’t export it, other files won’t be able to use it. Learn more about component structure in our upcoming Day 2 guide!

 

Pro Tips & Best Practices (Be a Smart Coder!)

 

  1. Save often: Get into the habit of saving your files regularly.
  2. Read the error messages: When something goes wrong, React and your browser will often give you helpful error messages. Don’t be scared of them! Try to read what they say, as they often point you directly to the problem.
  3. Use Google/Stack Overflow: Stuck on something? Chances are, someone else has had the same problem. Google is your best friend. Search for your error message or question, and you’ll often find solutions on sites like Stack Overflow.
  4. Practice, practice, practice: The more you code, the better you’ll become. Try changing other parts of the App.jsx file, add new text, or even try to put an image (we’ll cover images more later).
  5. Keep it simple at first: Don’t try to build Facebook on day one! Start with small, achievable goals.
  6. Don’t memorize everything: You don’t need to remember every single command or piece of code. Focus on understanding the concepts. You can always look up syntax when you need it.

 

Interview Questions You Might Encounter (Even on Day 1 Basics!)

 

Even at this early stage, understanding these foundational concepts is key. Here are a couple of questions you might hear:

  1. What is React JS?
    • Simple Answer: React JS is a JavaScript library for building user interfaces (UI). It helps us create web pages by breaking them down into small, reusable parts called components.
  2. What is JSX?
    • Simple Answer: JSX is a special syntax that lets us write HTML-like code directly inside our JavaScript files when using React. It makes writing React components much easier and more intuitive.
  3. What is a React Component?
    • Simple Answer: A React component is like a building block for your web application. It’s a small, self-contained piece of code that represents a part of your user interface, like a button, a navigation bar, or a whole section of a page.
  4. Why would you choose Vite over Create React App for a new project?
    • Simple Answer: Vite is generally faster for development because it uses native ES modules and only builds what’s necessary, leading to much quicker startup and hot module replacement times compared to bundler-based tools like Create React App.

 

Recap: What We Did Today

 

Phew! That was a lot for Day 1, but you did amazing!

  • We learned that React JS helps us build websites using reusable “LEGO bricks” called components.
  • We got our computer ready by installing Node.js and VS Code.
  • We created and ran our very first React application using the fast Vite tool.
  • We even made our app say “Hello, World!” by editing the App.jsx file.
  • We touched upon JSX, the HTML-like syntax we write in React.
  • And we learned about common pitfalls and how to become a smarter, more efficient coder!

You’ve taken a huge first step into the world of web development. Give yourself a pat on the back!


 

What’s Next for Day 2?

 

Tomorrow, on Day 2, we’re going to dive deeper into React Components. We’ll learn how to create our own custom components and how to pass information between them. Get ready to build more LEGO bricks! Check out our Introduction to MERN Stack: A Full Guide to see what’s coming in the next 29 days! (example internal link)


 

Follow Us!

Loved this Day 1 guide? Stay connected and don’t miss out on the rest of our 30-Day MERN Stack Challenge! Follow us on social media for daily updates, extra tips, and community discussions.

https://dev.mindwriter.in

Mindwriter AI

Hi, I'm Kiran T— founder of Mindwriter, a platform where AI meets creativity. I love building smart tools and writing blogs that simplify technology and self-growth.

🔴Related Post

Leave a Comment