Options
All
  • Public
  • Public/Protected
  • All
Menu

Module providers/ApiProvider

This file contains mix of React components and hooks useful for obtaining the ApiContext from any component in the project.

Variables

Functions

Variables

Const Context

Context: Context<ApiContext | PartialApiContext | NoApiContext> = React.createContext<ApiContext | PartialApiContext | NoApiContext>({ status: "NoProvider" })

Definition of React ApiContext context. Default value is invalid context with "NoProvider" status

Functions

Const ApiProvider

  • ApiProvider(__namedParameters: object): Element
  • React Component wrapping obtained children with ApiContext provider, so useApi and {@link useApiMaybe} can be called from any component in the children subtree. This is the only place where createApiContext is called. Internally it uses useDatabase and useNotify so it must be used under corresponding providers.

    Parameters

    • __namedParameters: object
      • children: undefined | null | string | number | false | true | object | ReactElement<any, string | function | object> | ReactNodeArray | ReactPortal

    Returns Element

Const useApi

  • React Hook for obtaining ApiContext from any component under ApiProvider. If full ApiContext with status OK cannot be obtained, error is thrown instead.

    Returns ApiContext

Const useMaybeApi

Generated using TypeDoc