Theory
The other big front end
You built FestConnect's front end in Angular, but the other dominant choice in the industry is React. A full-stack developer should recognise both. This closing lesson is a taste of React: enough to read it, see how it compares with Angular, and know it connects to the same Firebase backend.
React builds UIs from components written in JSX, and manages state and side effects with hooks like useState and useEffect. If you understand Angular's component thinking, React will feel familiar in spirit, though lighter and more flexible in style.
Theory
Components, JSX, and setup
React is a JavaScript library for building user interfaces from components. You start a project with Vite (fast and modern) or the older Create React App.
Modern React components are functions that return JSX, a syntax that lets you write HTML-like markup directly inside JavaScript. So a component is just a function whose return value describes what to render. This is lighter than Angular's class-and-decorator style: a React component can be a single small function. JSX mixing markup and logic in one place is React's signature look, and once it clicks, it reads very naturally.
Practical
A React functional component with useState
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0); // state: [value, setter]
return ( // JSX: HTML-like markup in JS
<button onClick={() => setCount(count + 1)}>
Clicked {count} times
</button>
);
}
export default Counter;This example runs in Gri-Learn on the web, where you can edit it and see the output.
Theory
Hooks: useState and useEffect
Hooks add capabilities to functional components.
useState gives a component state: const [count, setCount] = useState(0) returns the current value and a setter; calling the setter updates the value and re-renders the component. useEffect runs side effects after render, such as fetching data or subscribing, controlled by a dependency array that says when to re-run it (for example, once on mount with an empty array []).
So useState is 'remember a value and re-render when it changes', and useEffect is 'do something after rendering, like load data'. Together they cover most of what a component needs, and they are how React connects to Firebase for data and auth.
Practical
useEffect to load data once (e.g. from Firebase)
import { useState, useEffect } from 'react';
function Events() {
const [events, setEvents] = useState([]);
useEffect(() => {
// side effect: fetch once after first render (empty dependency array)
fetchEventsFromFirebase().then(setEvents);
}, []); // [] = run once on mount
return <ul>{events.map(e => <li key={e.id}>{e.name}</li>)}</ul>;
}
// React integrates with Firebase via the same client SDK used in Angular.This example runs in Gri-Learn on the web, where you can edit it and see the output.
Quiz
In a React functional component, what does the useState hook do?
- It defines the app's routes
- It gives the component a piece of state: it returns the current value and a setter, and calling the setter updates the value and re-renders
- It connects to the database directly
- It replaces JSX
Show the answer
It gives the component a piece of state: it returns the current value and a setter, and calling the setter updates the value and re-renders
useState adds state to a functional component: const [value, setValue] = useState(initial) returns the current value and a setter function; calling the setter updates the value and triggers a re-render so the UI reflects the change. Option A describes routing (handled by a router library, not useState). Option C is the job of a data-fetching effect or SDK (often inside useEffect), not useState itself. Option D is wrong: JSX is the markup syntax for what to render, while useState manages data; they work together, one does not replace the other. useState is React's way of remembering and updating a value that drives the UI.
Think first
Angular or React: how do they compare, and does it matter which you learn?
You now know both Angular and a bit of React. How do they differ, and should a full-stack developer worry about the choice? Then tap.
Show the answer
They solve the same problem, building component-based UIs, but with different philosophies, and knowing the CONCEPTS matters far more than the specific choice. ANGULAR is a full, opinionated FRAMEWORK: it comes with a lot built in (routing, forms, dependency injection, HttpClient), uses TypeScript by default, and prescribes a structured way to do things. That is powerful for large teams and apps because there is a standard way to do most tasks, though it means more to learn upfront. REACT is a lighter LIBRARY focused on the view: it gives you components, JSX, and hooks, and leaves many choices (routing, data fetching, state management) to you or to add-on libraries. That makes it flexible and quick to start, but you assemble more of the stack yourself. Neither is universally 'better', they trade structure for flexibility, and both power huge production apps. What truly transfers is the shared MENTAL MODEL you have been building: UIs as trees of reusable components, data flowing down through inputs/props, events flowing up, state driving what renders, and the same backend (Firebase, an API) underneath. Once you think in components and state, moving between Angular and React is mostly learning different syntax for the same ideas. So a full-stack developer should be comfortable reading both, understand the framework-versus-library trade-off, and pick based on the project and team, not agonise over which is 'right'. Learn the concepts deeply; the specific tool is a detail you can switch.
Theory
BCA603-01 complete
You have built a full-stack application concept end to end: an Angular front end (components, routing, forms, reusable UI, deployment), an Express/Node REST backend (routes, middleware, MongoDB via Mongoose), the two connected with JSON APIs and secured with Firebase Auth and JWTs, plus Firestore and a taste of React. That is the complete arc of full-stack web development. You can now reason about any layer of a modern web app, and connect them into a real, deployable product. A strong foundation for building on the web.
Summary
Key takeaways
- React is a popular JavaScript library for building UIs from components; set up with Vite or Create React App.
- Modern React components are functions that return JSX, an HTML-like syntax written inside JavaScript.
- useState gives a component state: it returns the value and a setter, and updating re-renders the component.
- useEffect runs side effects (like fetching data) after render, controlled by a dependency array (empty [] runs once on mount).
- React connects to the same Firebase backend (client SDK) used in Angular.
- Angular is a full opinionated framework; React is a lighter flexible library, but both share the component/state mental model.
- Memory hook: React = functional components in JSX, useState for state, useEffect for side effects; the concepts transfer from Angular.