Private
Public Access
1
0
Files
power-apps-codeapps-blog-part2/node_modules/@fluentui/react-context-selector/lib/useHasParentContext.js

17 lines
566 B
JavaScript

'use client';
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;
}