multi-downloader-nx_mirror/gui/react/src/hooks/useStore.tsx
2023-03-03 19:10:20 +01:00

12 lines
No EOL
393 B
TypeScript

import React from 'react';
import { StoreAction, StoreContext, StoreState } from '../provider/Store';
const useStore = () => {
const context = React.useContext(StoreContext as unknown as React.Context<[StoreState, React.Dispatch<StoreAction<keyof StoreState>>]>);
if (!context) {
throw new Error('useStore must be used under Store');
}
return context;
};
export default useStore;