Files
metabuilder/hooks/index.ts
johndoe6345789 78a54228df feat(hooks): Create centralized hooks npm package
- Added @metabuilder/hooks workspace package at root
- Consolidated 30 React hooks from across codebase into single module
- Implemented conditional exports for tree-shaking support
- Added comprehensive package.json with build/lint/typecheck scripts
- Created README.md documenting hook categories and usage patterns
- Updated root package.json workspaces array to include hooks
- Supports multi-version peer dependencies (React 18/19, Redux 8/9)

Usage:
  import { useDashboardLogic } from '@metabuilder/hooks'
  import { useLoginLogic } from '@metabuilder/hooks/useLoginLogic'

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-01-23 19:17:17 +00:00

27 lines
947 B
TypeScript

import { useDispatch, useSelector, TypedUseSelectorHook } from 'react-redux'
import { configureStore } from '@reduxjs/toolkit'
import { getMiddlewareConfig, getDevToolsConfig } from '../middleware'
// Types will be augmented when store is configured
export type RootState = any
export type AppDispatch = any
// Typed hooks for use throughout app
export const useAppDispatch = () => useDispatch<AppDispatch>()
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
// Helper to create typed store with provided reducers
export function createAppStore(reducers: any, preloadedState?: any) {
return configureStore({
reducer: reducers,
preloadedState,
middleware: getMiddlewareConfig(),
devTools: getDevToolsConfig(),
})
}
export type AppStore = ReturnType<typeof createAppStore>
// Re-export middleware utils for custom configuration
export { getMiddlewareConfig, getDevToolsConfig } from '../middleware'