Options
All
  • Public
  • Public/Protected
  • All
Menu

Module react-runtime/src/main

Index

Type aliases

LocaleProtocol

LocaleProtocol: [string, Dispatch<SetStateAction<string>>]

MessageProps

MessageProps<F>: F extends MessageFunction<infer Values> ? Values extends object ? { message: F; values: Values } : { message: F } : never

Type parameters

Variables

Const LocaleContext

LocaleContext: Context<LocaleProtocol> = ...

The context that provides current locale to Message and useMessage.

see

LocaleProvider

Const LocaleProvider

LocaleProvider: FC<ILocaleProviderProps> = ...

Provides a locale value and setter to underlying children.

Const Message

Message: MessageComponent = ...

Renders a message using a runtime from RuntimeContext and a locale from LocaleContext.

see

createMessageComponent

see

LocaleProvider

Const RuntimeContext

RuntimeContext: Context<IRuntime<ReactNode>> = ...

The context that provides IRuntime to Message and useMessage.

Functions

createMessageComponent

  • createMessageComponent<I18n>(runtimeContext: Context<IRuntime<ReactNode>>, i18nContext: Context<I18n>, localeSelector: (i18n: I18n) => string): MessageComponent
  • Creates a component that renders a message using a runtime provided through the runtimeContext.

    see

    Message

    Type parameters

    • I18n

      The type of the context that carries i18n data and provides the current locale.

    Parameters

    • runtimeContext: Context<IRuntime<ReactNode>>

      The context that provides a runtime to render a message.

    • i18nContext: Context<I18n>

      The context that holds i18n related data.

    • localeSelector: (i18n: I18n) => string

      The callback that returns a locale from i18n context value.

        • (i18n: I18n): string
        • Parameters

          • i18n: I18n

          Returns string

    Returns MessageComponent

createMessageHook

  • createMessageHook<Result, I18n>(runtimeContext: Context<IRuntime<Result>>, i18nContext: Context<I18n>, localeSelector: (i18n: I18n) => string): () => IMessageRenderer<Result>
  • Creates a React hook that returns a callback that renders a message function using runtime retrieved from runtimeContext.

    see

    useMessage

    Type parameters

    • Result

      The type of values

    • I18n

      The type of the context that carries i18n data and provides the current locale.

    Parameters

    • runtimeContext: Context<IRuntime<Result>>

      The context that provides a runtime to render a message.

    • i18nContext: Context<I18n>

      The context that holds i18n related data.

    • localeSelector: (i18n: I18n) => string

      The callback that returns a locale from i18n context value.

        • (i18n: I18n): string
        • Parameters

          • i18n: I18n

          Returns string

    Returns () => IMessageRenderer<Result>

      • Creates a React hook that returns a callback that renders a message function using runtime retrieved from runtimeContext.

        Returns IMessageRenderer<Result>

createReactRuntime

useLocale

  • useLocale(): [string, Dispatch<SetStateAction<string>>]

Const useMessage

Generated using TypeDoc