DAY 1 _ React Fundamentals
DAY 1 _ React Fundamentals
Fundamentals
Smriti Kumari
Senior Software Engineer
Accolite Digital, Hyderabad
What will you learn ?
● ReactJS is scalable
● Variables and Data Types: Understanding how to declare and assign values
to variables, and the different data types available in JavaScript such as
numbers, strings, booleans, null, and undefined.
● Functions: Understanding the basics of functions, including how to declare
them, pass arguments, and return values.
● Arrays: Understanding how to create and manipulate arrays in JavaScript,
including accessing elements, adding and removing elements, and iterating
over them.
● Objects: Understanding how to create and manipulate objects in
JavaScript, including creating object literals, accessing properties, and using
object methods.
● Conditionals: Understanding how to use conditional statements in
JavaScript, including if/else statements, switch statements, and ternary
operators.
JS Essentials
● Loops: Understanding how to use loops in JavaScript, including for loops, while
loops, and do-while loops.
● DOM Manipulation: Understanding how to manipulate the Document Object
Model (DOM) using JavaScript, including selecting elements, changing their
properties, and adding and removing elements.
● Events: Understanding how to handle events in JavaScript, including attaching
event listeners, event delegation, and using event objects.
● Promises: Understanding how to use promises in JavaScript, including creating
and chaining promises, and handling errors with catch.
● Asynchronous Programming: Understanding how to use asynchronous
programming techniques in JavaScript, including using setTimeout, setInterval,
and asynchronous functions like setTimeout.
Once you have a good grasp on these JavaScript essentials, you can begin learning
React, a popular JavaScript library for building user interfaces.
Real DOM vs Virtual DOM
In React, there are two types of Document Object Models (DOM) that are used: the
Real DOM and the Virtual DOM. Here are the key differences between the two:
1. Real DOM: The Real DOM is the actual HTML DOM that exists in the
browser. Whenever a change is made to the Real DOM, the browser needs to
re-render the entire page. This can be time-consuming and can result in slow
performance.
2. Virtual DOM: The Virtual DOM is a lightweight copy of the Real DOM.
Whenever a change is made to the Virtual DOM, React updates it and then
compares it to the previous version of the Virtual DOM. React then updates
only the parts of the Real DOM that have changed, resulting in faster
performance and better user experience.
Here are some of the advantages of using the
Virtual DOM in React
1. Faster performance: Because React only updates the parts of the Real DOM
that have changed, it results in faster performance and better user
experience.
2. Improved efficiency: React can update the Virtual DOM more efficiently than
the Real DOM, making it a more efficient way to handle UI updates.
3. Better debugging: Because the Virtual DOM is a lightweight copy of the Real
DOM, it can be easier to debug and troubleshoot issues.
4. Cross-platform compatibility: The Virtual DOM can be used on any platform,
making it a more versatile option for web developers.
5. Improved developer experience: React’s use of the Virtual DOM can make
the development process faster and more efficient, allowing developers to
focus on building great user interfaces rather than worrying about
performance issues.
JSX
Example 1
Components
Example 2
State and Props
Definition State is an object that represents the Props (short for properties) are values
current state of a component that are passed to a component from
its parent component
Mutability State is mutable, meaning it can be Props are immutable, meaning they
changed cannot be changed once they are
passed to a component
Ownership State is owned and managed by the Props are owned and managed by the
component itself parent component