@carbon/ibm-products
Version:
Carbon for IBM Products
32 lines (30 loc) • 905 B
JavaScript
/**
* Copyright IBM Corp. 2020, 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
import { createContext, useContext } from "react";
//#region src/components/Card/next/CardContext.tsx
/**
* Copyright IBM Corp. 2026
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Context for sharing Card state with child components
*/
const CardContext = createContext(void 0);
/**
* Hook to access Card context
* @returns CardContextValue
* @throws Error if used outside of Card component
*/
const useCardContext = () => {
const context = useContext(CardContext);
if (!context) throw new Error("Card subcomponents must be used within a Card component");
return context;
};
//#endregion
export { CardContext, useCardContext };