React-session
React-session
React JS
What is React?
- React is a JavaScript library that focuses on declarative syntax and
virtualization of DOM.
State Change: When state or props change, React creates a new VDOM tree.
Diffing Algorithm: React compares the new VDOM with the previous one to detect
changes.
Efficient Update: Only the changed parts of the real DOM are updated, improving
performance.
Virtual DOM & Rendering Flow
What is JSX?
- JSX (JavaScript XML) is a syntax extension for
JavaScript used in React.
1. UserProfile Component
This component will display the user's profile information, such as their name and email.
2. UserAvatar Component
This component will display the user's avatar (profile picture), passing the URL of the image as a
prop.
1. Function Components - Lightweight, Use hooks for state/lifecycle & uses in modern React
- Hooks are functions that let you “hook into” React state and lifecycle features from function
components.
- Simplifies stateful logic sharing across components.
- Enables cleaner, reusable, and more testable code.
- Eliminates need for this, constructor, and class-based syntax.
- Only call Hooks at the top level of the component.
- Only call Hooks from React functions (components or custom hooks).
- The Context API in React provides a way to share data between components without having
to pass props manually at every level of the component tree. It is particularly useful for
sharing data that is considered "global" for a tree of React components, such as the current
user, theme, or locale preferences
Note : Followed clean folder structure and component reuse for scalability.
Let’s do some practical