Posted by

in

Introduction to React: Understanding the Basics

Posted by:

|

On:

|

Image from Canva Pro

I keep talking about the other parts of React, but failed to post about: What is even React?

Can I eat that?

No. You cannot. But it can make you sob uncontrollably. I’m kidding.

React is a JavaScript library designed for building web applications known as single-page applications. These applications load a single HTML page and dynamically update content in response to user interactions without reloading the entire page.

React enhances the development process of web applications by enabling the division of code into reusable components.

As I have said in my previous posts, you can visualize those components as reusable blocks of code that you can use to build your app/website.

E.g. index.jsx

function Welcome() {

return

"Welcome to React"
;
}
Welcome to React Browser

Think of it as a function that returns that you want to be showing on the screen just like the image above!

In React, we often use the ES6 syntax to define components due to its modern features.

Although the styles differ, both approaches essentially create a function that returns content for React to render.

index.jsx

const WelcomeToTheNewWorld 
= () =>
{
return "Hello, new world";
};

function
WelcomeToTheOldWorld() {
return "Hello, old world";
}

If you’re a foodie, think of the component like a recipe. It instructs React what to “cook” (or display). You can reuse that recipe whenever it’s necessary.

Thus, whatever we return will be displayed once the component is rendered.

index.jsx

const Welcome = () => {

return

"I'll be displayed"
;

};

One of the best way to think about components as well: it is custom HTML tags but was bitten with super radioactive spider (yes, yes. I’ve been obsessing over Spiderman lately).

The function’s name defines the component which allows you to reuse it just like an HTML tag―just with the added functionality and flexibility.

index.jsx

const 
MyComponent
= () => {
return "I'm a component";
};

Components typically start with an uppercase letter unlike a regular HTML tag. Also, unlike the normal JavaScript functions, React components are CAPITALIZED.

In JavaScript: myComponent.

In React: MyComponent.

index.jsx

const 
MyComponent
= () => {
return "I'm a component";
};

In React, components aren’t limited to outputting just plain text; they can also return HTML elements.

For example, you can design a component to output an HTML heading containing specific text.

index.jsx

const WelcomeComponent = () => {
return
<h1>
Hello, world
</h1>
;
};

What you’re looking at is JSX, which resembles HTML but is not the same. JSX is a unique syntax that React utilizes to allow the writing of HTML-like code within JavaScript.

index.jsx

const WelcomeComponent = () => {
return
<
h1
>
I'm an imposter</h1>;
};

Although JSX isn’t actual HTML, it resembles and behaves similarly to HTML. If you’re familiar with HTML, you’ll find JSX quite intuitive.

React transforms JSX into genuine HTML, allowing your browser to interpret and display it as it would traditional HTML.

index.jsx

const TextComponent = () => {
return
<p>
Welcome
</p>
;
};
  1. You create a React component by writing a JavaScript function that returns JSX
  2. JSX: a syntax that looks like HTML but is actually JavaScript

Try out React for yourself! It will definitely save you lines and lines of code in the future (it’s also a great way to get you sobbing. LOL I’m joking).


  • We Outsourced Our Brains To AI…Now What?

    The article discusses the cognitive costs associated with increased reliance on AI tools and the internet, raising concerns about diminishing memory and critical thinking skills. It highlights the “Google Effect” and cognitive offloading, showing a correlation between AI dependence and decreased analytical abilities, particularly among younger users, while emphasizing the importance of maintaining cognitive engagement.

  • Hi besties! You don’t have to post everything about your life online.

    A raw yet insightful look at online oversharing, digital privacy, and how web design and content creation subtly shape your behavior. Learn why protecting your data and attention matters more than ever in an AI-curated world.

  • Hi, Humanity. Not Everything You Read Online Is Factual.

    Learn how to spot misinformation online by understanding SEO, AI bias, emotional manipulation, and the psychology behind digital content.

  • I Tried to Build an App…Now I’m in a Full Existential Spiral

    Choosing My Old App…and Accidentally Rebuilding a Whole Product So, I graduated in April 2025 with a glowing average of 95.8% (yes, mom, I know, why not A++? Just kidding) from UofT Continuing Studies – Software Development BootCamp, and instead of coding immediately like I probably should have, I sat there like: Hmm… what is…

  • Implementing Dark Mode in React

    We have previously talked about useState before. A great way to create CSS classes on the fly is to use state variable! Here is an example of how to create Dark Mode in React by using string interpolation to construct the individual classes based on the state variable mode. index.html index.jsx App.jsx App.css So, if…

  • Understanding React’s useState Hook

    Buttons To use buttons, you can add the onClick event handler to handle clicks on the button. React also follows the camelCase unlike HTML/JavaScript; and to run the JavaScript, you add an embedded expression. App.jsx You can also run JavaScript directly inside the embedded expression. However, it is executed without clicking the button because the function is…

  • Understanding Props in React: A Comprehensive Guide

    This content explains the concept of props in React, which allow data to be passed to components, making them dynamic. It covers how to access props as objects, pass multiple properties, and handle different data types. The importance of correctly rendering non-string values and using props in JSX is emphasized.

  • The Power of JSX: Combining HTML and JavaScript

    JSX is a syntax extension for JavaScript that resembles HTML, used primarily in React to create components. It allows developers to write HTML-like code within JavaScript, enhancing readability and enabling dynamic web applications. With JSX, one can embed JavaScript expressions, making the integration of logic and UI layout seamless.

  • Organizing React Components for Better Code

    The content discusses best practices for organizing React components in separate files for maintainability. It details the process of importing React, creating functional components, and exporting them. Additionally, it covers returning multiple elements and using named vs. default exports, emphasizing strategic organization for better code management.

  • Step-by-Step Guide to Rendering React Components

    The content provides a step-by-step guide on rendering components in React. It emphasizes creating and linking HTML and JavaScript files, setting up the main component, and utilizing the createRoot function to manage rendering. The author injects humor while guiding readers through the essential concepts of React component rendering.



Discover more from Steal My Notes

Subscribe to get the latest posts sent to your email.

Discover more from Steal My Notes Here

Subscribe now to keep reading and get access to the full archive.

Continue reading