Outlook_Addin_LLM/node_modules/@fluentui/react-context-selector/lib/useHasParentContext.js

16 lines
552 B
JavaScript

import * as React from 'react';
/**
* @internal
* Utility hook for contexts created by react-context-selector to determine if a parent context exists
* WARNING: This hook will not work for native React contexts
*
* @param context - context created by react-context-selector
* @returns whether the hook is wrapped by a parent context
*/ export function useHasParentContext(context) {
const contextValue = React.useContext(context);
if (contextValue.version) {
return contextValue.version.current !== -1;
}
return false;
}