mirror of
https://github.com/Nezumi-2711/react-training.git
synced 2026-09-22 05:32:07 +00:00
23 lines
558 B
TypeScript
23 lines
558 B
TypeScript
import { useContext } from 'react';
|
|
|
|
// Contexts
|
|
import { UserRoomAvailableContext } from '@src/contexts/UserRoomAvailableContext';
|
|
|
|
/**
|
|
* The hooks check the place call is in UserRoomAvailableProvider or not
|
|
* @returns The context of UserRoomAvailableContext
|
|
*/
|
|
const useUserRoomAvailable = () => {
|
|
const context = useContext(UserRoomAvailableContext);
|
|
|
|
if (context === undefined) {
|
|
throw new Error(
|
|
'UserRoomAvailableContext was used outside of UserRoomAvailableProvider'
|
|
);
|
|
}
|
|
|
|
return context;
|
|
};
|
|
|
|
export { useUserRoomAvailable };
|