fncheng Frontend Development Blog

website·Indexed 30 days ago

https://fncheng.github.io/blog

A collection of technical notes and tutorials focusing on frontend development, featuring React (React-Router 5/6/7, Redux, MobX, Zustand, TanStack Query, Next.js), Vue (reactivity and data hijacking), Webpack, qiankun micro-frontends, and general JavaScript concepts like event bubbling and AbortController.

Tokens
189.4K
Snippets
1.1K
Records
1.3K
Agent score
75%

What's inside fncheng Blog

  1. Overview of Git Hooks

    Git hooks are a custom mechanism that allows developers to run scripts when specific internal Git operations or external CLI commands are executed. They are divided into two categories:

    • Client-side hooks: Run in the local repository. Used to control local workflows (e.g., pre-commit, pre-push) to perform code checks or tests before committing or pushing.
    • Server-side hooks: Run on the Git server. Used for team collaboration and central repository management (e.g., pre-receive, post-receive) to trigger checks or deployments when code is pushed.

    Common hooks include:

    • pre-commit: For formatting, linting, and syntax checks.
    • post-commit: For notifications or logging after a successful commit.
    • pre-push: To ensure code quality and run tests before pushing to a remote.
    • post-receive: To update code, recompile, or deploy applications on the server.
  2. Understand HTTP Cookie basics and usage

    HTTP Cookies are small pieces of data sent by a server and stored in the user's browser. They are sent back to the server with every subsequent request to the same server, enabling state management over the stateless HTTP protocol. Common use cases include session management (login status, shopping carts), personalization (user themes), and browser behavior tracking.
  3. Understand the Flux architecture and its components

    Flux is a frontend architectural pattern designed to manage data flow in applications (originally for React) using a strict unidirectional data flow. It divides the application into four distinct layers:

    • View: The UI layer that displays data and triggers actions.
    • Action: Messages sent by the View (e.g., a mouseClick) that describe a state change. Actions typically package update information into an Action Payload object.
    • Dispatcher: A central hub that receives Actions and notifies all registered Stores.
    • Store: The data layer that holds the application state and implements the logic for state changes. When the state changes, the Store emits a change event to notify the View.
  4. Understand the React rendering mechanism

    React handles rendering in two distinct phases:

    1. Initial Render: React recursively renders the entire component tree from the top down (usually starting from App.tsx).
    2. Update Render: Unlike the initial render, updates are localized. A re-render is triggered from the component where state (via useState or setState) or props change.

    The Update Process:

    • React re-executes the render method (or function body for functional components) to generate a new Virtual DOM tree.
    • Diffing Algorithm: React compares the new Virtual DOM tree with the previous one. It only compares nodes at the same level (not globally) to find the minimum set of DOM updates required.
    • Local Rendering: React updates only the necessary parts of the real DOM based on the diff results, skipping unnecessary updates to optimize performance.
  5. Install GUI applications using Homebrew Cask

    Homebrew Cask is an extension of Homebrew used to install macOS GUI applications (such as .dmg or .pkg files) like Chrome or QQ. It automates the process of downloading, extracting to a unified directory (/opt/homebrew-cask/Caskroom), and symlinking the application to the ~/Applications/ directory, making installation and uninstallation cleaner than manual methods.
  6. Understand the MVVM pattern in Vue reactivity

    Vue implements a Model-View-ViewModel (MVVM) architecture to handle data binding:

    • Model: The application data and business logic.
    • View: The UI components and display effects.
    • ViewModel: The core framework that links the Model and View. It ensures that when data changes, the view updates, and when the view changes, the data updates.

    Key components of the ViewModel include:

    • Observer: Monitors all data properties for changes.
    • Compiler: Scans DOM elements for directives, replaces them with data, and binds update functions.
  7. Implement the Flux unidirectional data flow

    The Flux architecture ensures predictable state management by enforcing a one-way data loop:

    1. User Interaction: The user interacts with the View.
    2. Action Trigger: The View dispatches an Action.
    3. Dispatching: The Dispatcher receives the Action and notifies the Store(s).
    4. State Update: The Store updates its state based on the Action type (often using a Reducer logic) and emits a change event.
    5. View Update: The View listens for the change event and re-renders the UI to reflect the new state.
  8. Analyze the structure of an HTTP Request message

    When a client sends an HTTP request to a server, the message follows a specific format consisting of four parts:

    1. Request Line: Contains the method, URI, and HTTP version.
    2. Request Header: Contains metadata about the request.
    3. Empty Line: A blank line separating the headers from the body.
    4. Request Body (Data): The actual payload being sent to the server.