Professional Documents
Culture Documents
Submitted by
200140111015
BACHELOR OF ENGINEERING
in
Electronics and Communication Engineering
Government Engineering College, Bharuch
CERTIFICATE
Designing Using React” has been carried out by Aman Arun Rai under my
DECLARATION
Report has been carried out by me and has not been previously submitted to
I hereby warrant that the work I have presented does not breach any existing
copyright acts.
Student Sign :
iv
ACKNOWLEDGEMENT
I am immensely grateful for the enriching experience and knowledge I gained during my
online internship at INFOLABZ IT Services Pvt Limited. This experience has been
nothing short of transformative as I dived into the world of dynamic webpage designing
using ReactJS.
I would like to extend my heartfelt gratitude to Mr. Chintan Nagrecha, whose dedicated
ReactJS and its applications. His expertise and willingness to share his knowledge have
been a constant source of inspiration throughout the internship. Under his mentorship, I
have had the privilege of not only building projects but also delving into the intricacies of
APIs, React ES6, and various cutting-edge web development techniques. I also want to
express my appreciation to the entire team at INFOLABZ IT Services Pvt Limited for
providing me with the opportunity to work on real-world projects and learn within a
professional environment.
I would like to extend my sincerest of thanks to our internal guide Mr. Devendra R Patel
Enrollment : 200140111015
Student Sign :
v
ABSTRACT
From July 27th to August 10th, 2023, I embarked on a valuable journey as
an intern at INFOLABZ. In just 15 days, I was introduced to the world of
React, ES6, and cutting-edge frameworks in dynamic webpage design.
Through online mode, industry mentors guided me, bridging the gap between
theory and hands-on practice. The practical side of React and ES6 met the
knowledge I had gathered in college.
vi
List of Figures
Fig 1.1 JavaScript Function............................................................................................................2
Fig 1.2 External Script...................................................................................................................3
Fig 1.3 Alert Function.....................................................................................................................3
Fig 1.4 Async Loading....................................................................................................................3
Fig 1.5 Defer Loading.....................................................................................................................3
Fig 1.6 Variable Declaration...........................................................................................................4
Fig 1.7 Assignment in JavaScript....................................................................................................4
Fig 1.8 Initialization in JavaScript.................................................................................................4
Fig 1.9 Variable Scope...................................................................................................................5
Fig 1.10 Constant Variables............................................................................................................5
Fig 1.11 Naming Convention..........................................................................................................5
Fig 1.12 Dynamic Typing...............................................................................................................6
Fig 1.13 Hoisting in JavaScript.......................................................................................................6
Fig 1.14 Browser Support...............................................................................................................8
Fig 1.15 JavaScript Objects.............................................................................................................9
Fig 1.16 Code of Task...................................................................................................................10
Fig 1.17 Code of Task...................................................................................................................10
Fig 1.18 Code Output....................................................................................................................11
Fig 2.1 Simple JavaScript Function..............................................................................................13
Fig 2.2 Arrow Function Example..................................................................................................14
Fig 2.3 Async Function Example..................................................................................................15
Fig 2.4 Async Function Example..................................................................................................15
Fig 2.5 Data Fetching from Bitcoin API.......................................................................................18
Fig 2.6 Data Fetching from Covid API.........................................................................................19
Fig 2.7 Data Fetching from Covid API.........................................................................................19
Fig 2.8 Data Fetching from Covid API.........................................................................................20
Fig 2.9 Covid Portal......................................................................................................................20
Fig 2.10 Code for Covid Portal.....................................................................................................21
Fig 3.1 Alert Box...........................................................................................................................22
Fig 3.2 Accessing Form Data........................................................................................................22
Fig 3.3 Form Validation................................................................................................................23
Fig 3.4 Form Submission Handling..............................................................................................23
Fig 3.5 Code for Forms to Tables.................................................................................................25
vii
Fig 3.6 Form to Table Output........................................................................................................26
Fig 3.7 JavaScript Array Example................................................................................................26
Fig 3.8 Assignment.......................................................................................................................28
Fig 3.9 Assignment Code..............................................................................................................29
Fig 3.10 Assignment Output.........................................................................................................30
Fig 4.1 Node Installation...............................................................................................................33
Fig 4.2 React App Example..........................................................................................................34
Fig 4.3 Functional Components....................................................................................................34
Fig 4.4 React Class Component....................................................................................................35
Fig 4.5 Working of React..............................................................................................................36
Fig 5.1 Object Data.......................................................................................................................37
Fig 5.2 Map Function....................................................................................................................37
Fig 5.3 Data Mapping Using React...............................................................................................38
Fig 5.4 Mapping React Component..............................................................................................39
Fig 5.5 React Props.......................................................................................................................40
Fig 5.6 Installing Bootstrap...........................................................................................................41
Fig 5.7 Data Table Using React Bootstrap....................................................................................42
Fig 6.1 useEffect Hook..................................................................................................................44
Fig 6.2 Assignment 2....................................................................................................................45
Fig 6.3 Assignment Code..............................................................................................................46
Fig 6.4 Assignment Code..............................................................................................................46
Fig 6.5 Assignment Output...........................................................................................................47
Fig 7.1 Project Code 1...................................................................................................................48
Fig 7.2 Project Code 2...................................................................................................................48
Fig 7.3 Project Code 3...................................................................................................................49
Fig 7.4 Project Output...................................................................................................................49
Fig 7.5 Project Output...................................................................................................................49
viii
Table of Contents
CERTIFICATE.................................................................................................................................ii
CERTIFICATE OF COMPLETION...............................................................................................iii
DECLARATION.............................................................................................................................iv
ACKNOWLEDGEMENT................................................................................................................v
ABSTRACT.....................................................................................................................................vi
List of Figures.................................................................................................................................vii
Table of Contents.............................................................................................................................ix
CHAPTER 1......................................................................................................................................1
JAVASCRIPT INTRODUCTION....................................................................................................1
1.1 INTRODUCTION TO JAVASCRIPT....................................................................................1
1.2 JAVASCRIPT VARIABLES..................................................................................................4
1.3 INTRODUCTION TO ES6.....................................................................................................7
1.4 JAVASCRIPT OBJECTS.......................................................................................................9
CHAPTER 2....................................................................................................................................12
JAVASCRIPT FUNCTIONS & APIS............................................................................................12
2.1 FUNCTIONS........................................................................................................................12
2.1.1 Arrow Functions.................................................................................................................13
2.1.2 Async Functions.............................................................................................................14
2.2 WHAT IS AN API?..............................................................................................................16
2.3 BITCOIN API.......................................................................................................................17
2.4 COVID API...........................................................................................................................18
CHAPTER 3....................................................................................................................................22
JAVASCRIPT FORMS...................................................................................................................22
3.1 POP-UP BOXES...................................................................................................................22
3.2 FORMS.................................................................................................................................22
3.3 JS FORM TO VARIABLES.................................................................................................24
3.4 FORM TO TABLES.............................................................................................................24
3.5 JS ARRAYS..........................................................................................................................26
ASSIGNMENT...............................................................................................................................28
CHAPTER 4....................................................................................................................................31
REACTJS........................................................................................................................................31
4.1 REACT INTRODUCTION...................................................................................................31
4.2 INSTALLATION OF REACT..............................................................................................32
4.3 FUNCTIONAL COMPONENTS.........................................................................................34
ix
4.4 CLASS COMPONENTS......................................................................................................35
CHAPTER 5....................................................................................................................................37
REACT PROPS & BOOTSTRAP..................................................................................................37
5.1 VAR DATA MAP.................................................................................................................37
5.2 OBJECT DATA MAP :........................................................................................................38
5.3 REACT PROPS.....................................................................................................................40
5.4 REACT BOOTSTRAP :.......................................................................................................41
CHAPTER 6....................................................................................................................................43
REACT HOOKS.............................................................................................................................43
6.1 REACT HOOK.....................................................................................................................43
6.1.1 useState...........................................................................................................................43
6.1.2 useEffect.........................................................................................................................44
ASSIGNMENT 2............................................................................................................................45
CHAPTER 7....................................................................................................................................48
PROJECT........................................................................................................................................48
CONCLUSION...............................................................................................................................50
REFRENCES..................................................................................................................................51
x
Project ID - 337626 JAVASCRIPT INTRODUCTION
CHAPTER 1
JAVASCRIPT INTRODUCTION
1.1 INTRODUCTION TO JAVASCRIPT
JavaScript is a versatile, high-level programming language commonly used for web
development. It enables interactive and dynamic elements on websites, enhancing user
experience by allowing manipulation of content, animations, and interactions. As a client-
side scripting language, it runs directly in web browsers, facilitating responsive and
engaging web applications.
Inline Script: Place JavaScript directly within HTML using <script> tags. This is quick
but can clutter HTML.
External Script: Link an external JavaScript file using the <script> tag's src attribute.
JavaScript (script.js):
Async Loading: Load external scripts asynchronously for faster page rendering.
Defer Loading: Load external scripts while not blocking HTML parsing.
Assignment: Variables can hold different types of data: numbers, strings, objects,
etc.
Constants: Variables declared with const cannot be reassigned after their initial
value is set.
Hoisting: Variable declarations are "hoisted" to the top of their scope during
execution, but assignments remain in place.
need for explicit checks and providing more flexibility when calling functions.
Symbol: Symbols are unique and immutable data types that can be used as
property keys. They prevent unintentional property clashes in objects.
Iterators and Generators: ES6 introduced iterators and generators to facilitate
efficient looping through data structures and asynchronous programming.
Map and Set: These new data structures provide alternatives to objects and arrays
for certain use cases, offering better control and performance.
Array Methods (map, filter, reduce): These methods simplify array
manipulation and transformation, enhancing code readability and maintainability.
Enhanced Object Properties: ES6 brought shorthand syntax for defining object
methods and computed property names.
Async/Await: Building on top of Promises, async and await keywords provide a
more synchronous-like syntax for handling asynchronous operations.
ES6's features collectively improve JavaScript's ability to handle modern programming
challenges, enhance code organization, and create more efficient and maintainable
applications.
Here are the browsers that supports ES6 :
During the course of the internship, we delved into the realm of object-oriented
programming in JavaScript. One of the practical applications of this knowledge was
creating a dynamic table to display COVID-19 case data. Utilizing the principles of
object-oriented programming, we crafted a structured approach to represent and organize
the COVID-19 data.
By defining objects to encapsulate information about each case, we were able to create a
clear blueprint for how data should be organized. Each object contained properties such
as country, confirmed cases, recovered cases, and deaths. Through JavaScript's object-
oriented paradigm, we established a systematic framework for managing and
manipulating this data
JavaScript Objects: Objects are data structures that hold related information and
functionality. They consist of key-value pairs, where keys are strings and values can be of
various types.
TASK :
Displaying the Data of Objects into a tabular form using JavaScript
OUTPUT :
CHAPTER 2
JAVASCRIPT FUNCTIONS & APIS
2.1 FUNCTIONS
Functions are defined using the function keyword. The function name is followed by a set
of parentheses, which may contain arguments. The body of the function is enclosed in
curly braces.
Functions are a powerful tool that can be used to make JavaScript code more reusable,
organized, and efficient. They are a fundamental part of the language, and they are
essential for creating complex web applications.
This function takes an integer as its argument and returns the double of that integer.
(parameters) =>expression
The parameters are the arguments that the function takes. The expression is the body of
the function. The expression is evaluated, and the result is returned.
In this case, the function takes one parameter, x, and returns the value of x multiplied by
2.
Arrow functions can also be used without parameters. In this case, the parentheses are
optional.
Here is an example of an arrow function without parameters:
const greet = () => "Hello, world!";
Arrow functions have some subtle differences from regular functions. Here are a few of
the key differences:
Arrow functions do not have their own this keyword. The this keyword in an arrow
function refers to the object that called the function.
Arrow functions cannot be used as constructors.
Arrow functions cannot be used with the new keyword.
Arrow functions cannot be used with the call() or apply() methods.
Overall, arrow functions are a concise and powerful way to write anonymous functions in
JavaScript. They are a relatively new feature, but they are quickly becoming popular.
Here are some of the benefits of using arrow functions:
They are concise: Arrow functions are shorter than regular functions, which can make
your code more readable and easier to maintain.
They are efficient: Arrow functions do not have their own this keyword, which can
make them more efficient in some cases.
They are flexible: Arrow functions can be used in a variety of situations, including as
event handlers, callbacks, and anonymous functions.
An async function in JavaScript is a special type of function that is designed to work with
asynchronous operations, such as making network requests, reading files, or waiting for a
timer. Async functions are defined using the async keyword before the function
keyword.
In this example:
We define an async function fetchData.
Inside the function, we use the await keyword to pause execution until the fetch
function returns a promise. This promise resolves to a response object from the
API.
We then use await again to pause until the response is converted to JSON using
the response.json() method. This also returns a promise.
Finally, we log the JSON data to the console, handling any errors that may occur
with a try...catch block.
Async functions make it easier to work with asynchronous code in a more
synchronous-looking manner, which can improve code readability and
maintainability. They also allow you to handle errors more gracefully by using
try...catch.
API stands for "Application Programming Interface." It is a set of rules and protocols that
allows different software applications to communicate with each other. APIs define the
methods and data formats that applications can use to request and exchange information.
APIs are essential in modern software development and are used extensively in web
development, mobile app development, and many other areas of computing.
Here are some key points to understand about APIs:
Interoperability: APIs enable different software systems, written in different
languages or running on different platforms, to interact and work together. They
provide a standardized way for applications to communicate and share data.
Abstraction: APIs abstract the underlying complexity of systems. They allow
developers to interact with a service or system without needing to understand the
intricacies of its implementation. This abstraction simplifies the development
process.
Reuse: APIs promote code reuse. Instead of building a specific functionality from
scratch, developers can use existing APIs to add features or access data from other
services or systems. This saves time and effort.
Security: APIs often include security mechanisms, such as authentication and
authorization, to control access to data and services. This ensures that only
authorized users or applications can use the API.
Documentation: Good APIs come with clear and comprehensive documentation.
This documentation explains how to use the API, what data it expects, and what it
returns. It helps developers understand and use the API effectively.
Web APIs: These are APIs exposed over the internet using HTTP. They are
commonly used for web services, such as RESTful and GraphQL APIs.
Library APIs: These are APIs provided by libraries or frameworks to extend the
functionality of a programming language.
Operating System APIs: These allow software applications to interact with the
underlying operating system, accessing resources like files, hardware, and system
services.
Hardware APIs: These enable software to communicate directly with hardware
devices, like cameras, sensors, and printers.
RESTful APIs: Representational State Transfer (REST) is a common architectural
style for designing networked applications. RESTful APIs use HTTP methods
(GET, POST, PUT, DELETE) to perform CRUD (Create, Read, Update, Delete)
operations on resources, typically using JSON or XML as the data format.
GraphQL APIs: GraphQL is a query language for APIs that allows clients to
request exactly the data they need and nothing more. It offers a more flexible and
efficient way to retrieve data compared to traditional REST APIs.
In this example:
1. We use the fetch function to make an HTTP GET request to the CoinDesk API's
endpoint for current Bitcoin price data in JSON format
(https://api.coindesk.com/v1/bpi/currentprice.json).
2. We check the response status to ensure it's a successful response (HTTP status
code 200). If there's an error, we handle it by throwing an error.
3. If the response is successful, we parse the JSON data using response.json().
4. We access the Bitcoin price data in USD from the JSON response using
data.bpi.USD and log it to the console.
OUTPUT :
CHAPTER 3
JAVASCRIPT FORMS
3.1 POP-UP BOXES
Alert boxes are used to display a simple message to the user. They only have an "OK"
button, which the user can click to dismiss the message.
Confirm boxes are used to ask the user for confirmation. They display a message along
with "OK" and "Cancel" buttons.
3.2 FORMS
JavaScript can be used to work with HTML forms to validate input, handle form
submissions, and manipulate form elements dynamically. Here's an overview of how
JavaScript can be used with HTML forms:
1. Accessing Form Elements : You can access form elements in JavaScript using
their id, name, or by their position in the DOM. For example, to access an input
element with the id "username," you can use:
capture input values using .value. Validation ensures data accuracy. Through event
listeners, JavaScript intercepts the submission process, allowing developers to prevent the
default action, process data, and perform validations. This dynamic interaction enables
real-time updates, like modifying dropdown options based on user choices. JavaScript's
role in forms enhances user interaction and data handling on web pages, resulting in more
engaging and responsive experiences.
OUTPUT :
3.5 JS ARRAYS
JavaScript arrays are like lists that hold multiple pieces of data. Just like arranging items
in a row, arrays store different values in a single variable. You can put numbers, words, or
even objects in an array. Each item has a position called an index, starting from 0. For
example, in a shopping list array, the first item is at index 0, the second at index 1, and so
on. You can easily add or remove items from arrays, making them flexible. Arrays also
have helpful functions, called methods, for sorting, searching, and more. Learning about
arrays in JavaScript is like learning how to organize things neatly in a box so you can
access and manage them easily.
ASSIGNMENT
COVID data search tool that fetches information from an API based on user-provided
dates. The user enters a specific date, and the application retrieves relevant COVID-
related data for that date. The data is then neatly displayed in a tabular format for easy
comprehension.
The HTML and Bootstrap CSS is also used in this project but the main work of fetching
the data from Covid API is done by below JS code :
JS Code :
OUTPUT :
CHAPTER 4
REACTJS
4.1 REACT INTRODUCTION
ReactJS, often simply referred to as React, is an open-source JavaScript library for
building user interfaces (UIs) and user interface components for web applications. It was
developed and is maintained by Facebook and a community of individual developers and
companies. React is widely used for creating interactive and dynamic web applications.
Here are key features and concepts associated with React:
Component-Based: React is centered around the concept of reusable
components. Components are self-contained, modular pieces of code that
represent a part of the user interface. These components can be composed to build
complex user interfaces.
Virtual DOM: React uses a virtual representation of the DOM (Document Object
Model) called the Virtual DOM. When changes are made to the UI, React first
updates the Virtual DOM, then efficiently updates the actual DOM based on the
changes in the Virtual DOM. This approach helps improve performance.
Declarative Syntax: React promotes a declarative style of programming, where
you describe what the UI should look like at any given point in time. Developers
specify the desired UI state, and React takes care of updating the UI to match that
state.
One-Way Data Flow: In React, data flows in one direction, from parent
components to child components. This helps maintain a clear and predictable data
flow, making it easier to understand how data is shared and modified within an
application.
JSX (JavaScript XML): React uses JSX, a syntax extension for JavaScript that
allows developers to write HTML-like code within JavaScript. JSX makes it
easier to describe the UI components and their structure.
Component Lifecycle: React components have a lifecycle with various methods
that can be overridden to perform actions at different stages, such as when a
component is created, updated, or removed from the DOM. This provides control
over the behavior of components.
State Management: React allows components to manage their internal state,
which can change over time based on user interactions or other events. State
management in React helps create dynamic and interactive UIs.
Community and Ecosystem: React has a large and active community of
developers, which has led to the creation of a rich ecosystem of libraries and tools,
including state management libraries like Redux, routing libraries like React
Router, and UI component libraries like Material-UI.
Mobile Development: React can also be used for mobile app development
through the React Native framework. It allows developers to build native mobile
apps for iOS and Android using the same React components and principles used
in web development.
React's popularity is driven by its simplicity, performance optimizations, and the
developer-friendly ecosystem that has evolved around it. It's commonly used by
companies and developers to create single-page applications, progressive web apps, and
other interactive web interfaces.
We import the React library at the top. This is necessary because JSX (the HTML-like
syntax within the component) gets transpiled into React.createElement calls. We define a
function called Greeting which takes props (short for properties) as an argument. Props
are used to pass data from parent components to child components. Inside the Greeting
function, we return JSX that represents the UI. In this case, it's a simple heading that
greets a person by name. Finally, we export the Greeting component so that it can be
used in other parts of the application.
CHAPTER 5
REACT PROPS & BOOTSTRAP
5.1 VAR DATA MAP
In React, you can use the map function to iterate over an array of data and generate
dynamic content based on that data. This is often used to create lists or tables of items.
Here's how you can use the map function to render variable data in a React component:
Assuming you have an array of data like this:
You can use the map function to render this data in a React component:
In this example:
Install React Bootstrap: To install React Bootstrap, you can use npm or yarn. Open your
terminal, navigate to your project directory, and run one of the following commands:
Using npm:
Import Bootstrap CSS: To apply Bootstrap styles to your React components, you need
to import the Bootstrap CSS in your project.
Start Your React Application: If your development server isn't running already, start it
by running the following command in your project directory: npm start
CHAPTER 6
REACT HOOKS
6.1 REACT HOOK
React Hooks are functions that allow you to add state and other React features to
functional components. They were introduced in React 16.8 to enable developers to
manage state and side effects in functional components, making it easier to reuse logic
across components. Here's a brief explanation of some key React Hooks:
useState: Allows functional components to manage state. It takes an initial state value
and returns an array with the current state and a function to update it.
useEffect: Enables side effects in functional components, such as data fetching, DOM
manipulation, and subscriptions. It takes a function to run after rendering and can specify
dependencies to control when it runs.
Custom Hooks: Developers can create their own custom hooks to encapsulate and reuse
logic across components, promoting code reusability.
Overall, React Hooks allow functional components to have the same capabilities as class
components, making it easier to write clean, reusable, and maintainable code while
avoiding some of the complexities associated with class component
6.1.1 useState
useState is a React Hook that allows you to add state management to functional
components in React. It is one of the most commonly used hooks and enables you to
create and manage state variables within a functional component. Here's how useState
works:
Import useState: You need to import the useState function from the react library.
Declare State Variables: Inside your functional component, declare a state variable
using the useState function. The useState function takes one argument, which is the
initial state value.
In this example, we're declaring a state variable named count with an initial value of 0.
setCount is a function provided by useState that you can use to update the count state.
Access and Update State: You can access the current state value (in this case, count)
just like any other variable. To update the state, use the setCount function. It takes a new
value as an argument and triggers a re-render of the component.
6.1.2 useEffect
useEffect is a React Hook used for handling side effects (like data fetching or DOM
manipulation) in functional components. You pass it a function that runs after rendering,
and it can also take an optional dependency array to control when it runs. It's great for
managing async tasks and cleanup operations.
Example:
ASSIGNMENT 2
OUTPUT :
CHAPTER 7
PROJECT
A News App that fetches data from different APIs and renders on the page.
Code of the project :
After exporting from App.jsx, import the components in the Main.jsx. And, add css files
as per the design requirements.
OUTPUT:
CONCLUSION
In conclusion, my experience with ReactJS in dynamic webpage design has been both
enlightening and transformative. React's exceptional capabilities for creating dynamic,
interactive, and responsive web interfaces have opened new horizons in web
development.
Throughout this journey, I delved deep into React's core principles, including component-
based architecture and state management. This foundation allowed me to construct
webpages that adapt to user interactions in real-time, significantly enhancing the user
experience.
Working on dynamic webpage projects showcased the true power of React. Whether it
was dealing with real-time updates or crafting user dashboards with interactive charts,
React's versatility shone through.
REFRENCES
[1] https://infolabz.in/SI/react_internship
[2] https://react-bootstrap.netlify.app/docs/getting-started/introduction/
[3] https://react.dev/learn
[4] https://www.w3schools.com/react/default.asp