UNPKG

@designerstrust/remix-utils

Version:

This package contains simple utility functions to use with [Remix.run](https://remix.run).

25 lines (24 loc) 854 B
import type { Locales } from "../server/get-client-locales"; /** * Get the locales returned by the loader of the root route. * * This is useful to return the locales of the user once in the root and access * it everywhere in the UI without having to pass it as a prop or create a * custom context object. * * @example * // in the root loader * export let loader: LoaderFunction = async ({ request }) => { * let locales = getClientLocales(request); * return json({ locales }); * } * // in any route (including root!) * export default function Screen() { * let locales = useLocales(); * let date = new Date(); * let dateTime = date.toISOString; * let formattedDate = date.toLocaleDateString(locales, options) * return <time dateTime={dateTime}>{formattedDate}</time> * } */ export declare function useLocales(): Locales;