reviewer

Reviewer

View the Project on GitHub

Navigation: Index Azure .NET SQL React General

React

Virtual DOM

The Virtual DOM is a lightweight representation of the actual DOM in memory. React uses it to optimize updates to the real DOM by minimizing the number of changes needed. When the state of a component changes, React creates a new Virtual DOM tree and compares it with the previous one. This process is called “reconciliation.” React then updates only the parts of the real DOM that have changed.

DOM

Lifting State Up in React

Lifting state up refers to moving state from child components to a common parent component. This is done to share state between multiple child components. By lifting the state up, the parent component can manage the state and pass it down to the children via props.

React Design Patterns

Component Lifecycle

React components go through several lifecycle phases:

React Data Binding

React uses one-way data binding, where data flows from parent to child components via props. This ensures a unidirectional data flow, making the application easier to debug and maintain.

React Hooks

Hooks are functions that let you use state and other React features in functional components. Common hooks include:

Example:

import React, { useState, useEffect } from 'react';

function ExampleComponent() {
  const [count, setCount] = useState(0);

  useEffect(() => {
    document.title = `You clicked ${count} times`;
  }, [count]);

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>Click me</button>
    </div>
  );
}

Testing

SPA

A Single Page Application (SPA) loads a single HTML page and dynamically updates the content as the user interacts with the app. React is commonly used to build SPAs due to its efficient rendering and state management.

Class Component and Function Component in React

React State

State is an object that holds data that may change over the lifecycle of the component. It is managed within the component and can be updated using setState or useState.

React Props

Props (short for properties) are read-only attributes passed from parent to child components. They are used to pass data and event handlers to child components.

Difference Between State and Props

Stateful and Stateless Components

React Router

React Router is a library for handling routing in React applications. It allows you to define routes and navigate between different components.

Reducer

A reducer is a function that takes the current state and an action, and returns a new state. It is commonly used with the useReducer hook for managing complex state logic.

Redux

Redux is a state management library for JavaScript applications. It provides a centralized store for managing state and uses actions and reducers to update the state.

Context and Refs


← SQL | Back to Index | General →