/** * @license * Copyright 2025 Vybestack LLC * SPDX-License-Identifier: Apache-2.0 */ import type React from 'react'; import { createContext, useContext } from 'react'; import type { AppAction } from '../reducers/appReducer.js'; const AppDispatchContext = createContext | undefined>( undefined, ); export const AppDispatchProvider: React.FC<{ value: React.Dispatch; children: React.ReactNode; }> = ({ value, children }) => ( {children} ); export const useAppDispatch = (): React.Dispatch => { const dispatch = useContext(AppDispatchContext); if (!dispatch) { throw new Error('useAppDispatch must be used within AppDispatchProvider'); } return dispatch; };