react-native-trays
Version:
Production-grade, Family inspired, React Native Tray System library
28 lines (26 loc) • 848 B
JavaScript
;
/**
* hooks.ts
*
* Provides custom React hooks for interacting with the tray stack context and managing trays.
*/
import { useContext } from 'react';
import { TrayContext } from "./context.js";
/**
* useTrays
*
* Custom React hook to access tray stack manipulation functions for a specific stack.
* Throws an error if used outside of TrayProvider.
*
* @template T - The tray props type.
* @param stackId - The stack identifier to access.
* @returns Tray context functions for the given stack.
*/
export const useTrays = stackId => {
const getContext = useContext(TrayContext);
if (!getContext) throw new Error('useTrays must be used within TrayProvider');
const ctx = getContext(stackId);
if (!ctx) throw new Error('useTrays must be used within TrayProvider');
return ctx;
};
//# sourceMappingURL=hooks.js.map