@commercelayer/react-components
Version:
The Official Commerce Layer React Components
2 lines • 488 B
JavaScript
"use client";
import{useContext}from"react";export default function useCustomContext({context,key,currentComponentName,contextComponentName}){const currentContext=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}