@commercelayer/react-components
Version:
The Official Commerce Layer React Components
2 lines • 587 B
JavaScript
"use client";
;Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=useCustomContext;const react_1=require("react");function useCustomContext({context,key,currentComponentName,contextComponentName}){const currentContext=(0,react_1.useContext)(context),isProduction=process.env.NODE_ENV==="production",msg=`Cannot use <${currentComponentName}/> outside of <${contextComponentName}/>`;if(key!=null&&key in currentContext||key==null&¤tContext!=null)return currentContext;if(isProduction)console.error(msg);else throw new Error(msg);return currentContext}