Broadleaf Microservices
  • v1.0.0-latest-prod

Hooks Exports Bundle

Table of Contents

Export Package Name: hooks

How to pull in the module and its components
import { hooks } from '@broadleaf/admin-components';

const { useActions } = hooks;
Component Name Description

useActions

A hook used for retrieving the typed action definitions and their components from a given metadata object.

useAuthContext

A hook used to fetch the AuthContext.

useAvailableApplications

A hook used to fetch all available applications from TenantContext.

useCancelTokenFactory

A hook used to initialize a cancel token in a mutable ref object that can be used for cancelling requests. Any requests using the cancel token will be cancelled on cleanup.

useCollectionState

A hook used for managing the state & handlers for a paginated collection.

useCurrentApplication

A hook used to fetch the currently chosen application from TenantContext.

useCurrentTenant

A hook used to fetch the currently chosen tenant from TenantContext.

useDebouncedCallback

A hook used to return a debounced callback (a memoized function that will only invoke the callback function when the delay period has passed since the last invocation).

useEnhancedReducer

A hook used to return an enhanced useReducer hook which supports custom Redux-like middleware as the third parameter.

useExternalCollection

A hook used for instrumenting the useCollectionState hook and configuration of an ActionListGrid component for an external collection within a form.

useEventCallback

A hook used to create an event callback that will not change with every render. This is necessary in situations where you want to pass an event callback as a prop without resulting in re-renders of children components.

useHasAccess

A hook used to check whether the current user has access to the given scopes for the given operation types. If there is not a record with operation type information for a given scope, then this hook will request the operation data for that scope.

useHasAccessForEach

A hook used to check whether the user has access for each of the provided scope and operation type pairs. Used in useHasAccess to identify the result of the hook.

useInterval

A hook used to execute a callback on an interval. This hook uses a self-adjusting timer to properly handle delays in browser activity due to events such as browser inactivity.

useIsCheckingAccess

A hook used to check whether or not the given scopes are being checked for access by the current user from UserAccessContext. Essentially just checks whether the current user is being authorized or not.

useOnCaptureOutside

A hook used to trigger a handler whenever a click is made outside of a capturing component. The returned callback should be passed to the "capture" handler of the container component for the expected events.

useOnEscapeKeyDown

A hook used to attach the passed handler to run anytime a 'keydown' event is triggered.

usePollEffect

An effect hook used to execute the provided function on an interval. The interval strategy is determined by the options.strategy parameter, which is defaulted to poll every second.

useRefreshEffect

An effect hook used to implement fetch behavior on mount or in reaction to changes in dependencies.

useRouteLink

A hook used to connect to the set of routes and creating a link to a route’s location based on the provided link to/from a component. This hook uses ComponentRouterContext to return the latest set of routes.

useTenantActions

A hook used to return a memoized function that allows the user to perform tenant actions such as setting the application ID, setting the tenant ID, and fetching applications, among others.

useTenantContext

A hook used to fetch the TenantContext.

useToastContainer

A hook used to provide the state and helper functions for managing toasts. This hook is used in BaseLayout to help initialize the ToastContainerContext.

useTracking

A hook used to access the catalog and sandbox tracking context and state data that is set and updated by the TrackingContextProvider. Read more about this hook here.

useTranslateMode

A hook used to return the Translate Mode state from TranslateModeContext with a helper method to set the Translate Mode locale.