Skip to main content

useModalPanels Hook API Reference

File: packages/client/src/hooks/useModalPanels.ts Added: March 2026 (PR #1067)

Overview

Centralized React hook for subscribing to modal panel events (bank, store, dialogue, smelting, smithing, crafting, fletching, tanning, loot, quests, duels, trades). Provides state management and close handlers for all modal types. Shared between desktop and mobile interfaces.

Usage

Basic Usage

API

useModalPanels

Parameters:
Returns: ModalPanelsState (see Types section)

Types

ModalPanelsState

Panel Data Types

BankData

Note: RS3-style bank where placeholders are items with quantity: 0

StoreData

DialogueData

SmeltingData

SmithingData

CraftingData

FletchingData

TanningData

LootWindowData

QuestStartData

QuestCompleteData

XpLampData

DuelData

DuelResultData

TradeData

Event Handling

World Events

Network Events

Legacy UI_UPDATE Events

The hook handles legacy UI_UPDATE events for backwards compatibility: Economy Panels:
  • component: "bank" - Bank state updates
  • component: "store" - Store state updates
  • component: "dialogue" - Dialogue state updates
  • component: "dialogueEnd" - Dialogue ended
  • component: "smelting" - Smelting interface updates
  • component: "smithing" - Smithing interface updates
  • component: "crafting" - Crafting interface updates
  • component: "fletching" - Fletching interface updates
  • component: "tanning" - Tanning interface updates
Duel Panels:
  • component: "duel" - Duel interface opened
  • component: "duelRulesUpdate" - Duel rules changed
  • component: "duelEquipmentUpdate" - Equipment restrictions changed
  • component: "duelAcceptanceUpdate" - Acceptance state changed
  • component: "duelStakesUpdate" - Stakes changed
  • component: "duelStateChange" - Screen state changed
  • component: "duelClose" - Duel closed
  • component: "duelCancelled" - Duel cancelled
  • component: "duelCompleted" - Duel completed (shows result screen)
Trade Panels:
  • component: "trade" - Trade interface opened
  • component: "tradeUpdate" - Trade offer updated
  • component: "tradeConfirm" - Trade confirmation screen
  • component: "tradeClose" - Trade closed

Close Handlers

All close handlers are memoized with useCallback for stable references:

Panel-Specific Details

Bank Panel

Features:
  • RS3-style placeholders (items with quantity: 0)
  • Multi-tab support (up to 10 tabs)
  • Tab icons (set via right-click menu)
  • Always-set-placeholder toggle
  • Max 480 slots (expandable)
State Management:

Store Panel

Features:
  • Buy/sell items
  • Stock quantity tracking
  • Buyback rate (default 0.5 = 50% of value)
  • Category filtering
  • NPC entity tracking
State Management:

Dialogue Panel

Features:
  • NPC conversations
  • Multiple response options
  • Response effects (quest start, shop open, etc.)
  • NPC entity tracking for camera focus
State Management:

Duel Panel

Features:
  • Three-screen flow: RULES → STAKES → CONFIRMING
  • Combat rules (no ranged, no prayer, etc.)
  • Equipment restrictions (no weapon, no armor, etc.)
  • Stake items with value calculation
  • Acceptance tracking for both players
  • Opponent stake modification detection
State Management:

Trade Panel

Features:
  • Two-screen flow: offer → confirm
  • Item offer/remove
  • Acceptance tracking
  • Value calculation
  • Partner free slots tracking
State Management:

Cleanup

The hook properly cleans up all event listeners on unmount:

Benefits

  1. Centralized State: Single source of truth for all modal panels
  2. Shared Logic: Used by both InterfaceManager and MobileInterfaceManager
  3. Consistent Close Handlers: Memoized callbacks for stable references
  4. Type Safety: Strongly typed panel data structures
  5. Backwards Compatibility: Handles legacy UI_UPDATE events
  6. Proper Cleanup: All listeners removed on unmount
  7. Player ID Filtering: Quest/XP lamp events only for local player
  • usePlayerData - Centralized player data subscription (inventory, equipment, stats, coins)
  • useMinimapTerrainCache - Minimap terrain rendering
  • useMinimapEntityPips - Minimap entity markers
  • useMinimapWorldCaches - Minimap road/town caching

See Also