useText function

Module @runic-artifex/react in @runic-artifex/react 0.23.0

function useText(value: TextReference | FieldError | string | null | undefined, fallback?: string): string;

Renders a text reference that a ViewModel produced, such as a status line or a validation message's text, in the window's language (resolveText), and renders again when the language changes. A string renders as it is; null and undefined render fallback. Configure the page's Translations runtime once with configureTranslatedText; without one, a reference shows its fallback text. A field's FieldError renders the application's text for it (configureFieldErrorText), or its English message: useText(name.error).

const status = useText(view.state?.status);
<p>{status}</p>
{view.state?.validation.errors.map(error => <ErrorLine key={error.message} error={error} />)}
function ErrorLine({ error }) { return <li>{useText(error.text, error.message)}</li>; }