import { useContext } from 'react' ; import { MlContext , MlContextValue } from './ml_context' ; export const useMlContext = ( ) => { const context = useContext ( MlContext ) ; if ( context . combinedQuery === undefined || context . currentDataView === undefined || context . currentSavedSearch === undefined || context . dataViewsContract === undefined || context . kibanaConfig === undefined ) { throw new Error ( 'required attribute is undefined' ) ; } return context as MlContextValue ; } ;