Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Infiniflow Ragflow CommonHooks

From Leeroopedia
Knowledge Sources
Domains Frontend, React_Hooks
Last Updated 2026-02-12 06:00 GMT

Overview

Concrete collection of commonly reused React hooks for modal management, deep comparison, set operations, and responsive design in the RAGFlow frontend.

Description

The common-hooks.tsx module provides reusable hooks including: useSetModalState (modal open/close/loading management), useDeepCompareEffect (deep equality effect), useSetSelectedRecord (selection state management), useHandleSearchChange (debounced search input), and responsive breakpoint hooks.

Usage

Import these hooks throughout the frontend as utility primitives for common UI patterns like modal dialogs, search inputs, and selection state.

Code Reference

Source Location

Signature

export function useSetModalState(): {
  visible: boolean;
  showModal: () => void;
  hideModal: () => void;
  loading: boolean;
  switchLoading: () => void;
};

export function useDeepCompareEffect(effect: EffectCallback, deps: DependencyList): void;
export function useSetSelectedRecord<T>(): { currentRecord: T; setRecord: (r: T) => void };
export function useHandleSearchChange(): { searchValue: string; handleChange: (e) => void };

Import

import { useSetModalState, useDeepCompareEffect } from '@/hooks/common-hooks';

I/O Contract

Inputs

Name Type Required Description
Parameterless hooks; no external inputs

Outputs

Name Type Description
useSetModalState() object Modal state (visible, showModal, hideModal, loading)
useDeepCompareEffect() void Effect with deep comparison

Usage Examples

import { useSetModalState } from '@/hooks/common-hooks';

function MyPage() {
  const { visible, showModal, hideModal } = useSetModalState();
  return (
    <>
      <Button onClick={showModal}>Open</Button>
      <Dialog open={visible} onClose={hideModal} />
    </>
  );
}

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment