WDF Unit 5 Digital Notes
WDF Unit 5 Digital Notes
2
Please read this disclaimer before proceeding:
This document is confidential and intended solely for the educational purpose of
RMK Group of Educational Institutions. If you have received this document
through email in error, please notify the system manager. This document
contains proprietary information and is intended only to the respective group /
learning community as intended. If you are not the addressee you should not
disseminate, distribute or copy through e-mail. Please notify the sender
immediately by e-mail if you have received this document by mistake and delete
this document from your system. If you are not the intended recipient you are
notified that disclosing, copying, distributing or taking any action in reliance on
the contents of this information is strictly prohibited.
22IT407
WEB DEVELOPMENT FRAMEWORKS
(Lab Integrated)
Batch / Year / Semester: 2023-2027 / II / 4
4
1. CONTENTS
S.NO. CONTENTS PAGE NO
1 Contents 5
2 Course Objectives 6
3 Pre Requisites 7
4 Syllabus 8
5 Course Outcomes 13
6 CO- PO/PSO Mapping 14
7 Lecture Plan 15
8 Activity Based Learning 16
9 Lecture Notes 17-54
10 Assignment – 1 to 5 55-57
11 Part A Questions & Answers 58-77
12 Part B Questions 78
Supportive Online Certification
13 79
Courses
14 Real time Applications 80
15 Contents Beyond the Syllabus 81
16 Assessment Schedule 82
Prescribed Text Books & Reference 83
17
Books
18 Mini Project – 1 to 5 84-85
5
2. COURSE OBJECTIVES
OBJECTIVES:
6
3. PRE REQUISITES
• Pre-requisite Chart
22IT407
WEB DEVELOPMENT
FRAMEWORKS
22CS102
SOFTWARE DEVELOPMENT PRACTICES
7
4. Syllabus
22IT407 – WEB DEVELOPMENT FRAMEWORKS (Lab Integrated) – L T P C - 3 0 2 4
6
4. Syllabus
1) Develop a Scientific calculator that does following operations
➢ Rounded Value
➢ Area of Circle
➢ Calculating of Sin, Cos and Tan functions
➢ Permiter of a Rectangle
➢ Employ Arrow functions
➢ Employ HOC
UNIT III - REACT COMPONENTS – 9+6
Class vs Functional Components, Lifecycle methods - React Class Based Components
– component DidMount, WillUpdate, shouldupate, didcatchetc - State - UseState,
UseRef, USeEffect,UseHistory Usage and Props(difference, when to use what, mutable
or immutabilty,direction of flow), PropTypes, Auxillary Components, Controlled and
Uncontrolled Components,Component Interaction (Parent to Child and Child to
Parent), Iteration & Conditional Response
List of Exercise/Experiments
1) Create a collection of Customer by using
➢ Weak Map and Map Collection in JS
➢ Show Case the different feature set of the same.
2) Add Login Page, Dash Board Page, Admin Page
➢ Enable React Routing
➢ Add React Protected Route, for authorization
UNIT IV - REACT LIBRARY – I – 9+6
Event Bubbleup - Component Wrapper - Integration of CSS Modules - Forms
Validations(YUP, Formik, Standard), Events Handling, Data Binding - Redux
List of Exercise/Experiments
1) Develop a React application that has User Registration Form w field
level validations, data submission to a rest api end point, boot strap
for responsive.
➢ Use YUP or Formik to implement the same
4. Syllabus
2) Build a Redux Counter Application
Requirements:
➢ React application with Redux integrated.
➢ A counter with:
➢ Increment button
➢ Decrement button
➢ Reset button
➢ Display the current counter value.
UNIT V - REACT LIBRARY – II – 9+6
Custom Hooks, HTTP - Fetch, Axios, and Context API, Services, Behaviour Subjects -
StateLess, StateFulll and Container Components, Error Handling - Build, Env, CORS, Unit
Testing w React Testing Library - Introduction to react-native - Introduction to
StoryBook
List of Exercise/Experiments
1) Employ backend API for Login Page functionality (authentication). Post login, store
the user context (received from the back end server) in browser’s session storage as
objects. And use the same as creds during protected route verification.
➢ On the dashboard page, have a grid of Students. The data has to be bought from
backend api
➢ Employ useref, useeffect & usestate, and useHistory
2) Enable Exception Handling
3) Enable HOC and Aux Components
4) Implement React-Testing Library
5) Basic Context Setup
Objective: Set up a React Context to manage theme (light or dark).
➢ Create a ThemeContext using React.createContext.
➢ Create a provider component ThemeProvider with state to toggle between
"light" and "dark" themes.
➢ Use the context in a functional component to display the current theme.
➢ Add a button to toggle the theme.
4. SYLLABUS
Business Use Case Implementations
3) E-Commerce System
4) Student LMS Management System
TOTAL:45+30=75 PERIODS
TEXTBOOK:
1. David Flanagan, Javascript The Definitive Guide, Paperback, 7th Edition, 2020.
2. David Choi ,Full-Stack React, TypeScript, and Node: Build cloud-ready web
applications using React 17 with Hooks and GraphQL, Paperback – Import, 18
December 2020
3. Mehul Mohan, Advanced Web Development with React, Paperback – 1 January
2020
E-RESOURCES:
1.Parental Website - https://reactjs.org/
2.The Road to Learn React: Your journey to master plain yet pragmatic React.js by
Robin Wieruch.
3.Learning React: Functional Web Development with React and Redux by Alex Banks
and Eve Porcello
4. Learning React by KirupaChinnathambi
5. "React Up & Running" by StoyanStefanov
6. https://www.edureka.co/reactjs-redux-certification-training
7. CodePen
8. CodeSandbox (Preferred)
9. Stackblitz
11
4. SYLLABUS
LIST OF EQUIPMENTS:
• NodeJS (v9.11.2)
12
5. Course Outcomes
Course Outcomes with Knowledge Levels:
CO1: Personalize web pages using text formatting, graphics, audio,
and video. - K3
CO2: Hands on knowledge on Rest API , propTypes. - K3
CO3: Able to develop a web application using latest React
Framework – K3
CO4: Apply various React features including functions,
components, and services. – K3
CO5: Able to develop application using ReactJshooks. – K3
CO6: Design and integrate complex web components to enhance
user interface and user experience in React applications. – K5
11
6. CO-PO/PSO Mapping
CO2 3 2 3 1 2 - - - 2 1 - 1 - - -
CO3 3 3 3 1 2 - - 1 2 1 - 1 - - -
CO4 3 3 3 1 2 - - - 2 1 - 1 - - -
CO5 3 3 3 1 2 - - 1 2 1 - 1 - - -
CO6 2 3 3 - 3 - - 1 2 2 - 3 - - -
Correlation Level
1. Slight (Low)
2. Moderate (Medium)
3. Substantial (High) ,
If there is no correlation, put “-“.
12
7. LECTURE PLAN
Sl. Taxono
No. of. Proposed Actual Pertaining Mode of
No Topics my
Periods Date Date CO Delivery
. Level
As Per As Per
MD 1,
1 Custom Hooks 1 Academic Academic CO5, CO6 K3
MD 4
Calendar Calendar
As Per As Per
Behaviour Subjects MD 1,
4 1 Academic Academic CO5, CO6 K3
- StateLess MD 4
Calendar Calendar
As Per As Per
Error Handling - MD 1,
6 1 Academic Academic CO5, CO6 K3
Build, Env, CORS MD 4
Calendar Calendar
Unit Testing w As Per As Per
MD 1,
7 React Testing 1 Academic Academic CO5, CO6 K3
MD 4
Library Calendar Calendar
As Per As Per
Introduction to MD 1,
8 1 Academic Academic CO5, CO6 K3
react-native MD 4
Calendar Calendar
As Per As Per
Introduction to MD 1,
9 1 Academic Academic CO5, CO6 K3
StoryBook MD 4
Calendar Calendar
10 As Per As Per
- Lab Exercises 6 Academic Academic CO5, CO6 K3 Iamneo
15 Calendar Calendar
Common Activities
➢ The basic idea is that the game will present the user with a grid of randomly appearing
balloons, and the objective is to pop them to earn points. Each successful balloon pop will
what you will build. Or, explore the complete code from the GitHub repo of this project.
(https://github.com/c99rahul/pop-a-balloon)
9. Lecture Notes
Unit 5
REACT LIBRARY - II
Custom Hooks, HTTP - Fetch, Axios, and Context API, Services, Behaviour
Subjects - StateLess, StateFulll and Container Components, Error Handling -
Build, Env, CORS, Unit Testing w React Testing Library - Introduction to react-
native - Introduction to StoryBook
17
9. Lecture Notes – REACT LIBRARY - II
CUSTOM HOOKS
❑ Hooks are a new addition in React 16.8. They let you use state and other React features
without writing a class. Building your own Hooks lets you extract component logic into
reusable functions.
❑ When you have component logic that needs to be used by multiple components, we can
❑ Build a Hook
❑ In the following code, we are fetching data in our Home component and displaying it.
❑ We will use the JSONPlaceholder service to fetch fake data. This service is great for testing
❑ Use the JSONPlaceholder service to fetch fake "todo" items and display the titles on the
page:
useEffect(() => { f
etch("https://jsonplaceholder.typicode.com/todos")
<>
})}
</> ); };
root.render(<Home />);
❑ The fetch logic may be needed in other components as well, so we will extract that into a
custom Hook.
useFetch.js:
useEffect(() => {
index.js:
<>
})}
</>
); };
root.render(<Home />);
Explanation:
called useFetch which contains all of the logic needed to fetch our data.
We removed the hard-coded URL and replaced it with a url variable that can
In index.js, we are importing our useFetch Hook and utilizing it like any
other Hook. This is where we pass in the URL to fetch data from.
Now we can reuse this custom Hook in any component to fetch data from
any URL.
Hooks are a new addition in React 16.8. They let you use state and other
Building your own Hooks lets you extract component logic into reusable
functions.
o When we were learning about using the Effect Hook, we saw this component from a chat
application that displays a message indicating whether a friend is online or offline:
import React, { useState, useEffect } from 'react’;
function FriendStatus(props)
{
const [isOnline, setIsOnline] = useState(null); useEffect(() =>
{
function handleStatusChange(status)
{
setIsOnline(status.isOnline);
}
ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);
return () => { ChatAPI.unsubscribeFromFriendStatus(props.friend.id,
handleStatusChange);
};
});
if (isOnline === null)
{
return 'Loading...’;
}
return isOnline ? 'Online' : 'Offline’;
}
our chat application also has a contact list, and we want to render names of online users with
a green color. We could copy and paste similar logic above into our FriendListItem component
but it wouldn’t be ideal:
import React, { useState, useEffect } from 'react’;
function FriendListItem(props) {
setIsOnline(status.isOnline); }
ChatAPI.subscribeToFriendStatus(props.friend.id, handleStatusChange);
handleStatusChange); }; });
</li> );
❑ Instead, we’d like to share this logic between FriendStatus and FriendListItem.
❑ Traditionally in React, we’ve had two popular ways to share stateful logic between
components: render props and higher-order components. We will now look at how Hooks
solve many of the same problems without forcing you to add more components to the tree.
❑ When we want to share logic between two JavaScript functions, we extract it to a third
function. Both components and Hooks are functions, so this works for them too!
❑ A custom Hook is a JavaScript function whose name starts with ”use” and that may call other
Hooks.
function useFriendStatus(friendID)
useEffect(() => {
function handleStatusChange(status) {
setIsOnline(status.isOnline); }
ChatAPI.subscribeToFriendStatus(friendID, handleStatusChange);
handleStatusChange); }; });
return isOnline;
❑ There’s nothing new inside of it — the logic is copied from the components above. Just like
in a component, make sure to only call other Hooks unconditionally at the top level of your
custom Hook.
❑ Unlike a React component, a custom Hook doesn’t need to have a specific signature. We
can decide what it takes as arguments, and what, if anything, it should return. In other
words, it’s just like a normal function. Its name should always start with use so that you can
❑ The purpose of our useFriendStatus Hook is to subscribe us to a friend’s status. This is why
function useFriendStatus(friendID) {
return 'Loading...'; }
function FriendListItem(props) {
</li> ); }
❑ Is this code equivalent to the original examples? Yes, it works in exactly the same way. If
you look closely, you’ll notice we didn’t make any changes to the behavior. All we did was to
extract some common code between two functions into a separate function. Custom Hooks
are a convention that naturally follows from the design of Hooks, rather than a React
feature.
❑ This could be an external API or your own backend Node.js server, for example.
❑ By making a request, you expect your API to perform an operation according to the request
you made.
❑ For example, if you make a GET request, you expect to get back data to display in your
application.
❑ Axios has better error handling. Axios throws 400 and 500 range errors for you. Unlike the
Fetch API, where you have to check the status code and throw the error yourself.
❑ Axios can be used on the server as well as the client. If you are writing a Node.js
application, be aware that Axios can also be used in an environment separate from the
browser.
Using Axios with React is a very simple process. You need three things:
If you have an existing React project, you just need to install Axios with npm (or any other
package manager):
Here is a list of all the different routes you can make requests to, along with the appropriate
HTTP method for each:
How to Make a GET Request
First, you're going to make a request for individual posts. If you look at the endpoint, you are
React.useEffect(() => {
<div>
<h1>{post.title}</h1>
<p>{post.body}</p>
</div>
❑ To perform this request when the component mounts, you use the useEffect hook. This
involves importing Axios, using the .get() method to make a GET request to your endpoint,
and using a .then() callback to get back all of the response data.
❑ The response is returned as an object. The data (which is in this case a post with id, title,
and body properties) is put in a piece of state called post which is displayed in the component.
❑ Note that you can always find the requested data from the .data property in the response.
How to Make a POST Request
According to the API, this needs to be performed on the /posts endpoint. If you look at the
function createPost() {
<p>{post.body}</p>
❑ To make that POST request with Axios, you use the .post() method. As the second
argument, you include an object property that specifies what you want the new post to be.
Once again, use a .then() callback to get back the response data and replace the first post you
This is very similar to the .get() method, but the new resource you want to create is provided as
To do so, you'll once again create a button. But this time, the button will call a function to
update a post:
function updatePost() {
</div> ); }
❑ In the code above, you use the PUT method from Axios. And like with the POST method, you
❑ Again, using the .then() callback, you update the JSX with the data that is returned.
How to Make a DELETE Request
Note that you do not need a second argument whatsoever to perform this request:
React.useEffect(() => {
setPost(null) }); }
if (!post)
return (
❑ In most cases, you do not need the data that's returned from the .delete() method.
❑ But in the code above, the .then() callback is still used to ensure that your request is
successfully resolved.
❑ In the code above, after a post is deleted, the user is alerted that it was deleted successfully.
Then, the post data is cleared out of the state by setting it to its initial value of null.
❑ Also, once a post is deleted, the text "No post" is shown immediately after the alert message.
5.2. STATEFUL AND STATELESS COMPONENTS
State
A State is an object inside the constructor method of a class which is a must in the stateful
create components that are interactive and reusable. It is mutable and can only be changed
constructor(){
super();
render(){
Components
A React application is divided into smaller molecules, and each molecule represents a
component. In other words, a component is the basic building of a React application. It can
React components are independent and reusable and contains JSX(JavaScript XML Syntax)
which a combination of JS + HTML. It may take props as the parameter and returns a
Document Object Model(DOM) element that describes how the User Interface(UI) should
appear.
Class Component(Stateful)
constructor(){ super();
render(){
return (
<p>{this.state.first_name}</p>
<p>{this.state.last_name}</p> </div>
}}
Functional Component(Stateless)
function Example(props)
return
<div>
<p>{props.first_name}</p>
<p>{props.last_name}</p>
</div>
)}
Stateful components are those components which have a state. The state gets initialized in the
constructor. It stores information about the component’s state change in memory. It may get
Stateless Components
Stateless components are those components which don’t have any state at all, which means you
can’t use this.setState inside these components. It is like a normal function with no render
as componentDidMount and other hooks. When react renders our stateless component, all that
it needs to do is just call the stateless component and pass down the props.
❑ A stateless component can render props, whereas a stateful component can render both
props and state. A significant thing to note here is to comprehend the syntax distinction. In
stateless components, the props are displayed like {props.name} but in stateful components,
the props and state are rendered like {this.props.name} and {this.state.name} respectively. A
stateless component renders output which depends upon props value, but a stateful
component render depends upon the value of the state. A functional component is always a
What to Test
In general, your tests should cover the following aspects of your code:
❑ If a component renders with or without props
❑ How a component renders with state changes
❑ How a component reacts to user interactions
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1", “
web-vitals": "^2.1.4"
},
As you can see, Jest is not visible here. But, if you go to the node_modules folder, you will
see Jest there. So, no need to install it separately.
Also, make sure you have the following lines in your setupTests.js file:
import '@testing-library/jest-dom';
import '@testing-library/jest-dom/extend-expect';
Also, in your package.json file, modify your scripts like this:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --watchAll --coverage", “
eject": "react-scripts eject"
},
This will run your tests in watch mode and also show you the coverage (that is, the portion
of the code covered by your tests). You can also define the coverage threshold by adding
another property jest. For now, keep the threshold at 80%.
"jest": {
"coverageThreshold":
{
"global": {
"lines": 80
}}}
That’s it, now you are ready to start testing. Let’s first start with a basic test.
How to Write Your First Test for a React App
Let’s write a test for the following component:
const FirstTest = () => {
return (
<div>
<h2> First test </h2>
</div>
)
}
Here, we just need to test if the h2 element renders. Now, where should we write the tests?
We can write them inside a __tests__ folder anywhere in the src folder. The test file just
needs to have a .test.js/jsx extension and the test runner will pick it up.
This is how the test looks in our FirstTest.test.jsx file:
import { render, screen } from '@testing-library/react’
import FirstTest from '../components/FirstTest';
test("Example 1 renders successfully", () => {
render(<FirstTest/>);
const element = screen.getByText(/first test/i);
expect(element).toBeInTheDocument();
})
✓ First, import the required methods. The test() method contains an individual test. It takes
the name of the test and a callback function as the two arguments.
✓ Now, following the structure mentioned above, render the component you're testing using
the render method. Then, use the screen object to make a query for an element. In this
case, it’s the h2 element. Our query gets an element containing text that matches the
regex /first test/i (i means ignore case).
✓ Lastly, make the assertion using the expect method. We expect the element to be in the
document and it is, so the test passes.
✓ There are lots of other assertions you can make in your tests. Also, you can find a list of
ways to query an element from website. We’ll use some of them in our further examples.
How to Test With Mock Data in React
Here, we have a component with a prop data that displays a list of items. Let’s assume this
data comes from the backend and your component is displaying this data.
Let’s introduce some branching in the above component. We’ll have another
prop, displayUnorderedList, that determines whether to display an ordered or unordered list.
We’ll also render Senior for age > 50 and Not Senior otherwise.
import React from 'react'
const TestWithMockData = (
{
data, displayUnorderedList, handleClick}) => {
return (
<div>
{displayUnorderedList ?
<ul>
{
data.map(item => (
<li key={item.id}>
{item.id}
{item.first_name},
{item.last_name},
<a onClick={() => { console.log("email link clicked") handleClick() }}>{item.email}</a>
{item.age > 50 ? 'Senior' : 'Not senior'}
</li>
))}
</ul>
:
<ol>
{data.map(item => (
<li key={item.id}>
Last name: {item.last_name}
</li>
))}
</ol>
}
</div>
)}
export default TestWithMockData
Uncovered Branch
One line is still not covered by the test cases, which is the branching logic for age. So, add
another record to the mock data that has an age greater than 50.
{ "id": 3,
"first_name": "Amby",
"last_name": "Emmer",
"email": "[email protected]",
"age": 67
}
Now, all our tests should pass with 100% coverage.
Many different kinds of people use React Native: from advanced iOS developers to React
beginners, to people getting started programming for the first time in their career.
React Native: It is a framework developed by Facebook for creating native-style apps for
iOS & Android under one common language, JavaScript. Initially, Facebook only developed
React Native to support iOS. However, with its recent support of the Android operating
system, the library can now render mobile UIs for both platforms.
What is React Native?
➢ React Native (also known as RN) is a popular JavaScript-based mobile app framework that
allows you to build natively-rendered mobile apps for iOS and Android. The framework lets
you create an application for various platforms by using the same
codebase.
➢ React Native was first released by Facebook as an open-source project in 2015. In just a
couple of years, it became one of the top solutions used for mobile development. React
Native development is used to power some of the world’s leading mobile apps, including
Instagram, Facebook, and Skype. We discuss these and other examples of React Native-
powered apps further in this post.
➢ There are several reasons behind React Native’s global success.
➢ Firstly, by using React Native, companies can create code just once and use it to power
both their iOS and Android apps. This translates to huge time and resource savings.
➢ Secondly, React Native was built based on React – a JavaScript library, which was
already hugely popular when the mobile framework was released.
➢ Thirdly, the framework empowered frontend developers, who could previously only work
with web-based technologies, to create robust, production-ready apps for mobile
platforms.
➢ Interestingly, as with many revolutionary inventions, React Native was developed as a
response to...a big technological mistake.
Interactive examples
This introduction lets you get started immediately in your browser with interactive examples
like this one:
import React from 'react';
import {Text, View} from 'react-native';
The difference between React Native and other cross-platform development solutions (for
example, Cordova and PhoneGap) is that React Native doesn’t render WebViews in its code. It
runs on actual, native views and components. This is one of the reasons for React Native’s
spectacular success.
Fast applications
✓ Some claim that React Native code might have a detrimental effect on an app's
performance. Even though JavaScript code won't run as fast as native code, this difference
is unnoticeable to the human eye. To further prove it, we decided to run a test comparing
two versions of a simple application written in React Native and Swift – both achieved
similar performance results.
Future-proof
✓ Considering the pace at which the framework took over the market and its simple approach
to resolving development problems, the future of React Native for cross-platform apps
looks bright. Even though it has a few disadvantages, which we’ll discuss in the next
section, its speed and convenience of development compensate for them.
https://javascript.plainenglish.io/react-native-creating-a-simple-application-298fa0637e72
Storybook is the most popular UI component development tool for React, Vue, and Angular. It
helps you develop and design UI components outside your app in an isolated environment.
Learn Storybook to create bulletproof UI components, along the way you’ll build an app UI
from scratch.
Set up React Storybook
We'll need to follow a few steps to get the build process set up in our environment. To start
with, we want to use degit to set up our build system. Using this package, you can download
"templates" (partially built applications with some default configuration) to help you fast track
your development workflow.
Let’s run the following commands:
# Clone the template
npx degit chromaui/intro-storybook-react-template taskbox
cd taskbox
# Install dependencies
Yarn
Now we can quickly check that the various environments of our application are working
properly:
# Start the component explorer on port 6006:
yarn storybook
# Run the frontend app proper on port 5173:
yarn dev
We’ll begin with a baseline implementation of the Task, simply taking in the attributes we
know we’ll need and the two actions you can take on a task (to move it between lists):
import React from 'react';
export default function Task(
{
task: { id, title, state }, onArchiveTask, onPinTask })
{
return (
<div className="list-item">
<label htmlFor="title" aria-label={title}>
<input type="text" value={title} readOnly={true} name="title" />
</label>
</div>
); }
Above, we render straightforward markup for Task based on the existing HTML structure of
the Todos application.
Below we build out Task’s three test states in the story file:
❑ There are two basic levels of organization in Storybook: the component and its child
stories. Think of each story as a permutation of a component. You can have as many
stories per component as you need.
Component
Story
Story
Story
❑ To tell Storybook about the component we are documenting and testing, we create
a default export that contains:
❑ component -- the component itself
❑ title -- how to group or categorize the component in the Storybook sidebar
❑ tags -- to automatically generate documentation for our components
❑ To define our stories, we'll use Component Story Format 3 (also known as CSF3 ) to build
out each of our test cases. This format is designed to build out each of our test cases in a
concise way. By exporting an object containing each component state, we can define our
tests more intuitively and author and reuse stories more efficiently.
❑ Arguments or args for short, allow us to live-edit our components with the controls addon
without restarting Storybook. Once an args value changes, so does the component.
❑ When creating a story, we use a base task arg to build out the shape of the task the
component expects. Typically modeled from what the actual data looks like. Again, export-
ing this shape will enable us to reuse it in later stories, as we'll see.
10. ASSIGNMENT – 1 To 5
1) Facebook Ads and React Native : (CO5,CO6,K3)
The social networking platform isn’t the only React Native application that was developed
under Facebook’s roof. Facebook Ads was actually the first React Native app for Android and,
the first fully React Native based, cross-platform app built in the company.
The framework seemed perfectly suitable for the lot of complex business logic required to
accurately handle differences in ad formats, time zones, date formats, currencies, currency
conventions, and so on, especially that a big chunk of it was already written in JavaScript.
On top of that, implementation of UI surfaces with much data would be much easier with
React Native.
Numerous components developed alongside with the Facebook Ads app have been useful for
other developers in building their apps.
Read more about the first fully React Native app from Facebook.
Uber has recently shared their insights about leveraging React Native in engineering
of their food delivery app. Unlike the standard Uber app, Uber Eats marketplace involves
three parties: restaurants, delivery-partners and eaters. Such model required an extra
dashboard for restaurants.
The original Restaurant Dashboard was built for the web and it provided limited access to
the native device functionalities, such as sound notifications which was
a crucial problem for user experience.
10. ASSIGNMENT – 1 To 5
As the team had a great deal of experience using React but limited iOS/Android exposure
they decided to rebuild the dashboard with RN.
Although the framework constitutes only a small part of technology stack used in Uber
Eats, developers are very positive about its possibilities and capacity that can help them
meet needs as the marketplace grows.
without writing a class. Building your own Hooks lets you extract component logic into
reusable functions.
❑ When you have component logic that needs to be used by multiple components, we can
❑ Build a Hook
❑ In the following code, we are fetching data in our Home component and displaying it.
❑ We will use the JSONPlaceholder service to fetch fake data. This service is great for testing
❑ Use the JSONPlaceholder service to fetch fake "todo" items and display the titles on the
page:
useEffect(() => { f
etch("https://jsonplaceholder.typicode.com/todos")
function FriendListItem(props) {
return ( <li style={{ color: isOnline ? 'green' : 'black' }}> {props.friend.name} </li> ); }
5. How to fetch and Axios with react and why use AXIOS (CO5,K2)
❑ Axios is an HTTP client library that allows you to make requests to a given endpoint:
❑ This could be an external API or your own backend Node.js server, for example.
❑ By making a request, you expect your API to perform an operation according to the request
you made.
❑ For example, if you make a GET request, you expect to get back data to display in your
application.
❑ Here are five reasons why you should use Axios as your client to make HTTP requests:
❑ It has good defaults to work with JSON data. Unlike alternatives such as the Fetch API, you
often don't need to set your headers. Or perform tedious tasks like converting your request
❑ Axios has function names that match any HTTP methods. To perform a GET request, you
❑ Axios does more with less code. Unlike the Fetch API, you only need one .then() callback to
First, you're going to make a request for individual posts. If you look at the endpoint, you are
<p>{post.body}</p> </div>
❑ To perform this request when the component mounts, you use the useEffect hook. This
involves importing Axios, using the .get() method to make a GET request to your
endpoint, and using a .then() callback to get back all of the response data.
❑ The response is returned as an object. The data (which is in this case a post with id, title,
and body properties) is put in a piece of state called post which is displayed in the
component.
❑ Note that you can always find the requested data from the .data property in the response.
❑ According to the API, this needs to be performed on the /posts endpoint. If you look at
the code below, you'll see that there's a button to create a post:
❑ To make that POST request with Axios, you use the .post() method. As the second
argument, you include an object property that specifies what you want the new post to be.
❑ Once again, use a .then() callback to get back the response data and replace the first post
❑ This is very similar to the .get() method, but the new resource you want to create is
❑ To do so, you'll once again create a button. But this time, the button will call a function to
update a post:
<p>{post.body}</p>
</div> ); }
❑ In the code above, you use the PUT method from Axios. And like with the POST method,
you include the properties that you want to be in the updated resource.
❑ Again, using the .then() callback, you update the JSX with the data that is returned.
❑ Note that you do not need a second argument whatsoever to perform this request:
deleted!");
setPost(null) }); }
if (!post)
❑ In most cases, you do not need the data that's returned from the .delete() method.
❑ But in the code above, the .then() callback is still used to ensure that your request is
successfully resolved.
❑ In the code above, after a post is deleted, the user is alerted that it was deleted
successfully. Then, the post data is cleared out of the state by setting it to its initial value
of null.
❑ Also, once a post is deleted, the text "No post" is shown immediately after the alert
message.
State
A State is an object inside the constructor method of a class which is a must in the stateful
components. It is used for internal communication inside a component. It allows you to create
components that are interactive and reusable. It is mutable and can only be changed by using
setState() method.
constructor(){
super();
render(){
Components
A React application is divided into smaller molecules, and each molecule represents a
component. In other words, a component is the basic building of a React application. It can be
which a combination of JS + HTML. It may take props as the parameter and returns a
Document Object Model(DOM) element that describes how the User Interface(UI) should
appear.
Class Component(Stateful)
constructor(){ super();
render(){
return (
<p>{this.state.first_name}</p>
<p>{this.state.last_name}</p> </div>
) }}
Stateful Components
Stateful components are those components which have a state. The state gets initialized in the
constructor. It stores information about the component’s state change in memory. It may get
Stateless Components
Stateless components are those components which don’t have any state at all, which means
you can’t use this.setState inside these components. It is like a normal function with no render
as componentDidMount and other hooks. When react renders our stateless component, all that
it needs to do is just call the stateless component and pass down the props.
14. Mention with example for Stateful & Stateless Component (CO5,K2)
❑ A stateless component can render props, whereas a stateful component can render both
props and state. A significant thing to note here is to comprehend the syntax distinction. In
stateless components, the props are displayed like {props.name} but in stateful
output which depends upon props value, but a stateful component render depends upon the
value of the state. A functional component is always a stateless component, but the class
constructor(props){
super(props);
render(){
return (
<div>
<p>{this.state.value}</p>
<p>{this.props.value}</p>
</div>
) }}
✓ In the most simple terms, React Native isn’t a ‘newer’ version of React, although React
Native does use it.
✓ React (also known as ReactJS) is a JavaScript library used for building the frontend of a
website. Similarly to React Native, it was also developed by the Facebook engineering
team.
✓ Meanwhile, React Native – which is powered by React – lets developers use a set of UI
components to quickly compile and launch iOS and Android apps.
✓ Both React and React Native use a mixture of JavaScript and a special markup language,
JSX. However, the syntax used to render elements in JSX components differs between
React and React Native applications. Additionally, React uses some HTML and CSS, whereas
React Native allows the use of native mobile user interface elements.
24. How do the project structure looks for React Native. (CO5,K2)
Storybook is the most popular UI component development tool for React, Vue, and Angular. It
helps you develop and design UI components outside your app in an isolated environment.
Learn Storybook to create bulletproof UI components, along the way you’ll build an app UI
from scratch.
29. What makes React Native unique? (CO5,K2)
The difference between React Native and other cross-platform development solutions (for
example, Cordova and PhoneGap) is that React Native doesn’t render WebViews in its code. It
runs on actual, native views and components. This is one of the reasons for React Native’s
spectacular success.
30. How to Get set up Story Book? (CO5,K2)
First, let’s create the task component and its accompanying story
file: src/components/Task.jsx and src/components/Task.stories.jsx.
We’ll begin with a baseline implementation of the Task, simply taking in the attributes we
know we’ll need and the two actions you can take on a task (to move it between lists):
import React from 'react';
export default function Task(
{
task: { id, title, state }, onArchiveTask, onPinTask })
{
return (
<div className="list-item">
<label htmlFor="title" aria-label={title}>
<input type="text" value={title} readOnly={true} name="title" />
</label>
</div>
); }
12. PART B : Questions
Q. CO
Questions K Level
No. Level
https://www.coursera.org/learn/react-basics
• https://www.udemy.com/course/react-the-complete-
guide-incl-redux/learn/
• https://cs50.harvard.edu/web/2020/
79
14. REAL TIME APPLICATIONS
1) A WEB APPLICATION PROVIDING RANGE OF OPTIONS TO CAR BUYERS
Car selling website is where the customer can buy and sell their car. This website is
user friendly and ease to use for any customer, it has effective search box to get the
precise and suitable car for the user. A rich search facility is always there from where
customer can search vehicle via category, keywords, price range, brand, types, fuel
types, etc. The website displays information of the customer support person on the
homepage so that user can directly contact them or meet them which help in
decreasing the communication gap. This website also provides a facility for road side
assistance. The social media plugin will help the company to know their popularity over
the social media.
This application is developed for users who are interested in playing fantasy sports
online. Users can play fantasy sports with close friends or people you met over the
internet. Users can create their own leagues and can invite friends to play in their
league or they can play in others leagues. Users can easily change the league size,
payment deadlines, payout verifications and payout timelines. This system guarantee
the professional safekeeping of the funds through full-featured security measures.
User can withdraw funds from their account. User can refer a friend to play a particular
league.
Responsive web design is a way of making a single website that works effectively on
both desktop browsers and the myriad of mobile devices on the market. It involves
having a website that enhances the viewing experience, irrespective of which device is
being used. Bootstrap makes the front-end web development faster and easier. It is
made for the users of all skill levels, devices of all shapes and projects of all sizes. It is
considered the most popular HTML, CSS, and JavaScript framework for developing
responsive & mobile-first websites. With a responsive website design,
80
15. CONTENT BEYOND SYLLABUS
1. Automating Visual Regression Testing
What: Detect unintended visual changes by comparing snapshots of components over
time.
Tools: Integrate tools like Chromatic or Storyshots (part of Jest).
Why: Ensures UI consistency, especially in large projects with many contributors.
Implementation: Reusable Pipeline for User Data Processing.
Example:
Set up Storyshots:
npx storybook init
npm install @storybook/addon-storyshots
Create a test file:
import initStoryshots from '@storybook/addon-storyshots’;
initStoryshots();
2. Managing Complex Component Hierarchies
What: Organize stories to reflect the actual component structure.
How: Use CSF (Component Story Format) and nested folders.
Why: Keeps the Storybook clean and easier to navigate as your project grows.
Example:
export default {
title: 'Components/Forms/LoginForm',
component: LoginForm,
};
3. Storybook Controls and Dynamic PropsWhat: Create dynamic, interactive stories using
Controls.Why: Allows non-developers (like designers) to experiment with props directly in
the UI.
Example:
export default {
title: 'Button',
component: Button,
argTypes: {
backgroundColor: { control: 'color' },
size: { control: { type: 'select', options: ['small', 'medium', 'large'] } },
}, };
const Template = (args) => <Button {...args} />;
export const Primary = Template.bind({}); 81
Name of the
S.NO Start Date End Date Portion
Assessment
As per schedule after
1 Unit Test 1 UNIT 1
Unit I completion
2 IAT 1 28.01.2025 03.02.2025 UNIT 1 & 2
163
82
17. PRESCRIBED TEXT BOOKS
&
REFERENCE BOOKS
TEXT BOOKS:
1. Andy Harris, “HTML5 and CSS3 All-in-One For Dummies Book”, 3rd Edition, 2014.
2. David McFarland, “JavaScript and JQuery: Interactive Front-End Web
Development”.
REFERENCES:
2. Deitel, Deitel, Goldberg, "Internet and World Wide Web How To Program",
3. Marty Hall and Larry Brown, “Core Web Programming”, Pearson Education,
5. https://www.w3schools.com/js/js_es6.asp
6. http://es6-features.org/
7. https://www.tutorialspoint.com/es6/index.htm
83
18. MINI PROJECT – 1 to 5
1) E-COMMERCE SITE : (CO5,CO6,K5)
An e-commerce site allows users to browse and search for products, add them to a cart,
and check out using a dummy payment system. To build this app, you can create
a Product component that represents a single product and a ProductList component that
contains a list of Product components. The Product component should accept information
about the product, such as its name, price, and image, and render it along with a Add to
cart button. The ProductList component should accept an array of products and render
a Product component for each. You can also create a Cart component that displays the
items in the user’s cart and allows them to remove items or check out.
A calendar app allows users to view, add, and edit events in a calendar. To build this app,
you can create a Calendar component that displays the current month and year and the
days of the week. You can then create an Event component representing a single event and
an EventList component containing a list of Event components. The Event component
should accept information about the event, such as its name, date, and time, and render
this information in a user-friendly way. The EventList component should accept an array of
events and render an Event component for each. You can also add features such as
switching between months and viewing events for specific dates.
A weather app shows the current weather for a given location. To build this app, you can
use the OpenWeatherMap API to fetch weather data for a given location. You can then
create a Weather component that accepts a location and displays the current temperature,
humidity, and other relevant information for that location. You can also add a search form
that allows users to enter a location and see the current weather for that location.
18. MINI PROJECT – 1 to 5
4) A RECIPE APP : (CO5,CO6,K5)
A recipe app allows users to search for recipes and save their favorites. To build this app,
you can use the Spoonacular API to fetch recipe data. You can then create
a Recipe component representing a single recipe and a RecipeList component containing a
list of Recipe components. The Recipe component should accept information about the
recipe, such as its name, ingredients, and instructions, and render this information user-
friendly. The RecipeList component should accept an array of recipes and render
a Recipe component for each. You can also add a search form that allows users to enter a
keyword and see a list of matching recipes.
This allows users to create and track tasks, set deadlines, and organize them into different
categories. This project can be implemented using React, React Hooks for state
management, and CSS for styling. To create tasks, students can use the useState hook to
store the list of tasks in the component’s state and render an input field where users can
enter their task description. To set deadlines, students can use the DatePicker component
from the react-datepicker library to allow users to select a date for their task.
Thank you
Disclaimer:
This document is confidential and intended solely for the educational purpose of
RMK Group of Educational Institutions. If you have received this document through
email in error, please notify the system manager. This document contains
proprietary information and is intended only to the respective group / learning
community as intended. If you are not the addressee you should not disseminate,
distribute or copy through e-mail. Please notify the sender immediately by e-mail if
you have received this document by mistake and delete this document from your
system. If you are not the intended recipient you are notified that disclosing,
copying, distributing or taking any action in reliance on the contents of this
information is strictly prohibited.
86