UNPKG

@openshift-console/dynamic-plugin-sdk

Version:

Provides core APIs, types and utilities used by dynamic plugins at runtime.

20 lines (19 loc) 704 B
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore: FIXME out-of-sync @types/react-redux version as new types cause many build errors import { useSelector } from 'react-redux'; /** * Hook that retrieves all current k8s models from redux. * * @returns An array with the first item as the list of k8s model and second item as inFlight status * @example * ```ts * const Component: React.FC = () => { * const [models, inFlight] = UseK8sModels(); * return ... * } * ``` */ export const useK8sModels = () => [ useSelector(({ k8s }) => k8s.getIn(['RESOURCES', 'models']))?.toJS() ?? {}, useSelector(({ k8s }) => k8s.getIn(['RESOURCES', 'inFlight'])) ?? false, ];