Lesson 4 & 5 Advanced Web Programming

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/45

flashcard set

Earn XP

Description and Tags

React Event - State Management

Last updated 2:34 PM on 9/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

46 Terms

1
New cards

React Event

an action performed by the user or the browser.

2
New cards

onClick

User clicks an element

3
New cards

onDoubleClick

Double Click

4
New cards

onChange

Input Value Change

5
New cards

onSubmit

Form submission

6
New cards

onMouseEnter

Mouse enters element

7
New cards

onMouseLeave

Mouse leaves element

8
New cards

onKeyDown

Key is pressed

9
New cards

onKeyUp

Key is released

10
New cards

React uses camelCase for event names.

<button onClick={clickMe}>
- onClick
- Curly Braces {}
- Function reference (without parentheses)

11
New cards

Example of Button Click Event

Output: “Welcome, Click the button below to see the greeting”
“click me” button

<p>Output: “Welcome, Click the button below to see the greeting” <br>“click me” button</p>
12
New cards

Example of Passing Parameters

Output: “click button” > Hello Christian

<p>Output: “click button” &gt; Hello Christian</p>
13
New cards

React State

is a built-in React object that stores data that may change over time.

  • makes applications interactive.

  • Whenever State changes:

  • React automatically updates the UI.

  • The component re-renders.

  • The latest data is displayed.


14
New cards

Why do wee need State

Without State:
Data cannot change dynamically.

UI remains static.

User interactions have no visible effect.

15
New cards

Why do wee need State

With State:
Counters update.

Forms respond instantly.

Shopping carts change.

Dashboards refresh automatically.

16
New cards

useState Hook/ React Hook

  • useState is a ______ that allows a functional component to store and update data.

  • Whenever the stored data changes, React automatically updates the screen


17
New cards

useState React Hook

Syntax:
const [state, setState] = useState(initialValue);

Example:
const [count, setCount] = useState(0)';

count - holds the current value of the state.
setCount - function used to update the value of count.
useState(0) - sets the initial value to 0.

18
New cards

How useState Works

  • We are importing the useState hook from React so your component can remember values between renders.

  • Without useState, a variable would reset every time the component renders.


19
New cards

setState()

Before Hooks existed, React mainly used Class Components.

update state using:
this.setState({

count: count +1
});

functional components use:
setCount(count +1);


20
New cards

setState() vs useState()

setState()

  • used in class components

  • uses this.setState()

  • more code

  • older react approach

  • still supported


useState()

  • used functional components

  • uses useState() Hook

  • less code

  • modern react approach

  • reccomend for new projects


21
New cards

setState()

  • used in class components

  • uses this.setState()

  • more code

  • older react approach

  • still supported


22
New cards

useState()

  • used functional components

  • uses useState() Hook

  • less code

  • modern react approach

  • reccomend for new projects


23
New cards

React Stateless Components

is a React component that does not manage its own state.

Instead, it simply receives data from its parent component through Props and displays that

data.

It is also called a Presentational Component because its primary purpose is to present

information.

24
New cards

Characteristics of React Stateless Components

Does not use useState()

Does not use setState()

Receives data through Props

Displays UI only

Easy to reuse

Easy to test and maintain

25
New cards

Real-World Examples of Stateless Components

Website Header

Navigation Bar

Footer

Company Logo

Product Card

User Profile Card

Course Card

News Card

Employee Information Card

Contact Card

26
New cards

React Advanced Components

  • are reusable components and libraries that simplify th development of modern web applications.

  • Instead of building everything from scratch, developers use existing libraries to create applications faster and more efficiently


27
New cards

Example of React Advanced Components

Navigation Bars

Sidebars

Cards

Tables

Maps

Pagination

Responsive Layouts6

28
New cards

React Pagination

  • divides a large amount of data into smaller pages.

  • Instead of displaying hundreds of records at once, only a limited number are shown.


29
New cards

Why Use Pagination

Reduces the amount of information

displayed at one time.

Makes a page easier to read.

Improves navigation.

Organizes large datasets.

Can improve application performance.

Prevents long and crowded pages.

30
New cards

React Material UI (MUI)

  • is an open-source React component library that implements

  • It provides ready-to-use components such as buttons, cards, dialogs, forms, navigation bars, and tables.


31
New cards

Example of MUI Components

Button

Card

TextField

AppBar

Alert

Dialog

Table

Grid

32
New cards

Default Material UI installation

npm install @mui/material @emotion/react @emotion/styled

33
New cards

Default Material UI installation for Material Icon

npm install @mui/icons-material

34
New cards

React Bootstrap

  • is a library that rebuilds Bootstrap components as React components.

  • It replaces Bootstrap’s JavaScript behavior with React-based components and does not require jQuery.


35
New cards

Example of React Bootstrap

Container

Row

Col

Navbar

Card

Button

Modal

Form

Alert

36
New cards

Installing Bootstrap

npm install react-bootstrap bootstrap

37
New cards

Import Bootstrap Stylesheet in main.jsx

import “bootstrap/dist/css/bootstrap.min.css”;

38
New cards

React Map

displays geographical information inside a React application.

39
New cards

React Map can be used to display

Business locations

School locations

Hospitals

Disaster evacuation centers

Hazard areas

Delivery locations

User locations

Routes and destinations

40
New cards

React Leaftlet

provides React bindings for the mapping library. It uses ____ functionality through React components.

41
New cards

Installing React Leaflet

npm install leaflet react-leaflet

42
New cards

React Table

displays structured information using rows and columns.

43
New cards

Example of React Table

Student records

Employee records

Product lists

Sales reports

Attendance records

Enrollment records

Inventory records

44
New cards

Common Table Features

An advanced React table may include:

Search

Sorting

Filtering

Pagination

Row selection

Data formatting

Editable rows

Delete actions

Responsive desig

45
New cards

Installing TanStack React Table

npm install @tanstack/react-table

46
New cards

TanStack Table

  • is a headless table library. It provides table logic while allowing developers to control the final design and markup

  • A basic table can be created using HTML elements. For more advanced functions, developers can use libraries such as __________