Skip to content

Fix/state management cleanup - #345

Merged
El-swaggerito merged 2 commits into
Axionvera:mainfrom
DevALVIN-24:fix/state-management-cleanup
Jul 29, 2026
Merged

Fix/state management cleanup#345
El-swaggerito merged 2 commits into
Axionvera:mainfrom
DevALVIN-24:fix/state-management-cleanup

Conversation

@DevALVIN-24

Copy link
Copy Markdown
Contributor

Closes #334

Summary

Clean up dashboard state management patterns by standardizing how custom hooks expose global state to React components.

Changes

  • Refactored useVault.ts: Removed duplicate local state logic. The hook now re-exports useVault, useVaultContext, and VaultProvider from @/contexts/VaultContext.
  • Refactored useGovernance.ts: Removed duplicate local state logic. The hook now re-exports useGovernance, useGovernanceContext, and GovernanceProvider from @/contexts/GovernanceContext.
  • Updated Contexts: VaultContext.tsx and GovernanceContext.tsx now export useVault and useGovernance aliases respectively, to match the pattern used in WalletContext.tsx.
  • Updated Components: Standardized all imports of useVaultContext and useGovernanceContext to use the unified hooks @/hooks/useVault and @/hooks/useGovernance. Affected components include dashboard.tsx, analytics.tsx, governance.tsx, AnalyticsDashboard.tsx, MemoizedAnalyticsDashboard.tsx, GlobalSearch.tsx, and features/governance/index.ts.
  • Added Documentation: Created docs/state_management.md to document the convention that hooks proxy the context and global state lives in Context, preventing future regressions.

Why

Previously, useVault.ts and useGovernance.ts maintained their own copies of state which was heavily duplicated with their corresponding context providers VaultContext.tsx and GovernanceContext.tsx. This led to unnecessary duplication and lack of clear state ownership. This PR clarifies state ownership by strictly delegating global state to Context and using hooks simply to expose this state to components, mirroring the clean architecture of WalletContext.

Verification

Manually verified that types compile and existing UI components integrate smoothly with the standardized hooks.

@El-swaggerito
El-swaggerito merged commit a9a7aaa into Axionvera:main Jul 29, 2026
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up Axionvera dashboard state management

2 participants