= {
[k in IntlPropName]: IntlShape
}
export type WithIntlProps = Omit
& {
forwardedRef?: React.Ref
}
export default function injectIntl<
IntlPropName extends string,
P extends WrappedComponentProps = WrappedComponentProps
>(
WrappedComponent: React.ComponentType,
options?: Opts
): React.FC> & {
WrappedComponent: React.ComponentType
}
export default function injectIntl<
IntlPropName extends string = 'intl',
P extends WrappedComponentProps = WrappedComponentProps,
T extends React.ComponentType = any
>(
WrappedComponent: React.ComponentType
,
options?: Opts
): React.ForwardRefExoticComponent<
React.PropsWithoutRef> & React.RefAttributes
> & {
WrappedComponent: React.ComponentType
}
export default function injectIntl<
IntlPropName extends string = 'intl',
P extends WrappedComponentProps = WrappedComponentProps,
ForwardRef extends boolean = false,
T extends React.ComponentType = any
>(
WrappedComponent: React.ComponentType
,
options?: Opts
): React.ForwardRefExoticComponent<
React.PropsWithoutRef> & React.RefAttributes
> & {
WrappedComponent: React.ComponentType
} {
const {intlPropName = 'intl', forwardRef = false, enforceContext = true} =
options || {}
const WithIntl: React.FC
}> & {
WrappedComponent: React.ComponentType
} = props => (
{(intl): React.ReactNode => {
if (enforceContext) {
invariantIntlContext(intl)
}
const intlProp = {[intlPropName]: intl}
return (
)
}}
)
WithIntl.displayName = `injectIntl(${getDisplayName(WrappedComponent)})`
WithIntl.WrappedComponent = WrappedComponent
if (forwardRef) {
return hoistNonReactStatics(
React.forwardRef((props: P, ref) => (
)),
WrappedComponent
) as any
}
return hoistNonReactStatics(WithIntl, WrappedComponent) as any
}