import { useCallback } from 'react' ; import useAuthProvider from './useAuthProvider' ; const getPermissionsWithoutProvider = ( ) => Promise . resolve ( [ ] ) ; see useAuthProvider returns { Function } see usePermissions example const useGetPermissions = ( ) : GetPermissions => { const authProvider = useAuthProvider ( ) ; const getPermissions = useCallback ( ( params = { } ) => authProvider . getPermissions ( params ) , [ authProvider ] ) ; return authProvider ? getPermissions : getPermissionsWithoutProvider ; } ; param { Object } params return { Promise } type GetPermissions = ( params ? : any ) => Promise < any > ; export default useGetPermissions ;