"hooks/useIsActive" | @uirouter/react
Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "hooks/useIsActive"

Index

Functions

Functions

useIsActive

  • useIsActive(stateName: string, params?: any, exact?: boolean): boolean
  • A hook that returns true if a given state is active.

    Example:

    function ContactsLabel() {
     const isActive = useIsActive('contacts');
     return <span className={isActive ? 'active' : 'inactive'}>Contacts></span>
    }

    Example:

    function JoeLabel() {
     const isActive = useIsActive('contacts.contact', { contactId: 'joe' });
     return <span className={isActive ? 'active' : 'inactive'}>Joe></span>
    }

    Parameters

    • stateName: string

      the name of the state to check. Relative state names such as '.child' are supported. Relative states are resolved relative to the state that rendered the hook.

    • Default value params: any = null

      if present, the hook will only return true if all the provided parameter values match.

    • Default value exact: boolean = false

      when true, the hook returns true only when the state matches exactly. when false, returns true if the state matches, or any child state matches.

    Returns boolean

Generated using TypeDoc