Files
mastodon/app/javascript/flavours/glitch/components/intl.tsx
Echo f780570f2d [Glitch] Refactor: Update FormatJS
Port 1820a03622 to glitch-soc

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2026-03-25 22:07:25 +01:00

27 lines
792 B
TypeScript

import type { ComponentClass } from 'react';
import { useIntl } from 'react-intl';
interface IntlHocProps<TProps extends Record<string, unknown>> {
component: ComponentClass<TProps>;
props: TProps;
}
export const IntlHoc = <TProps extends Record<string, unknown>>({
component: Component,
props,
}: IntlHocProps<TProps>) => {
const intl = useIntl();
return <Component {...props} intl={intl} />;
};
export const injectIntl = <TProps extends Record<string, unknown>>(
Component: ComponentClass<TProps>,
) => {
const WrappedComponent = (props: Omit<TProps, 'intl'>) => (
<IntlHoc component={Component} props={props as TProps} />
);
WrappedComponent.displayName = `injectIntl(${(Component.displayName ?? Component.name) || 'Component'})`;
return WrappedComponent;
};