import React from 'react' ; import useObservable from 'react-use/lib/useObservable' ; import { ILicense } from '../../../../licensing/public' ; import { useApmPluginContext } from '../apm_plugin/use_apm_plugin_context' ; import { InvalidLicenseNotification } from './Invalid_license_notification' ; export const LicenseContext = React . createContext < ILicense | undefined > ( undefined ) ; export function LicenseProvider ( { children } ) { const { license$ } = useApmPluginContext ( ) . plugins . licensing ; const license = useObservable ( license$ ) ; const hasInvalidLicense = license ?. isActive === false ; if ( hasInvalidLicense ) { return < InvalidLicenseNotification />; } return < LicenseContext . Provider value = { license } children = { children } / > ; }