Day 85 of
#100DaysOfCode
Weekend Review: JavaScript Libraries, Frameworks & React Fundamentals
This weekend, I revisited the foundations that power most of modern frontend development, JavaScript libraries, frameworks, and React basics.
Here’s what I covered 👇
🔹 Libraries vs Frameworks
Libraries are focused and flexible. You call their functions when you need them, e.g., jQuery for DOM manipulation or React for UI components.
Frameworks provide structure and rules. They call your code, not the other way around, e.g., Angular or Next.js.
Frameworks are ideal for building full applications, while libraries give you the freedom to structure things yourself.
🔹 Single Page Applications (SPAs)
SPAs load once and dynamically update the page as users interact — no full reloads.
Built with frameworks like React or Angular, they’re fast and smooth but come with tradeoffs:
Accessibility issues for screen readers
Navigation and bookmarking challenges
Slower initial load
🔹 React Essentials
React is a JavaScript library for building reusable UI components.
It works by keeping a virtual DOM and re-rendering components only when state or props change.
Components are the core of React, small, reusable functions that return UI:
function Greeting() {
const name = "Anna";
return <h1>Welcome, {name}!</h1>;
}
🔹 Importing & Exporting Components
React projects are modular, each component can be exported and imported across files:
// City.js
export default function City() {
return <p>New York</p>;
}
// App.js
import City from './City';
🔹 Setting Up a React Project with Vite
Vite makes React project setup fast:
npm create vite@latest my-react-app -- --template react
cd my-react-app
npm install
npm run dev
Your app runs at http://localhost:5173, and you’re ready to code.
🔹 Passing Props
Props (short for properties) are how data flows from parent to child components.
They make components dynamic and reusable:
function Child({ name }) {
return <h1>Hello, {name}!</h1>;
}
You can also use the spread operator to pass multiple props easily.
🔹 Conditional Rendering
React lets you conditionally render content using:
Ternary operators → {isLoggedIn ? "Welcome" : "Please log in"}
Logical AND (&&) → {user && <h1>Hi, {
user.name}</h1>}
if statements for more complex logic
🔹 Rendering Lists
When you have an array of data, you can render lists dynamically using map():
<ul>
{
names.map((name, index) => (
<li key={index}>{name}</li>
))}
</ul>
Always include a unique key to help React optimize rendering.
🔹 Inline Styles
You can style JSX elements directly using JavaScript objects:
<h1 style={{ color: "blue", fontSize: "20px" }}>Hello!</h1>
or conditionally:
const styles = {
color: isImportant ? "red" : "black",
};
🧩 Takeaway
This week’s review reinforced how React builds on core JavaScript principles, components, data flow, and reactivity, while frameworks like Next.js extend those ideas for full-scale app development.
Next up: diving deeper into state management, side effects, and data fetching in React.