All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s
17 lines
472 B
JavaScript
17 lines
472 B
JavaScript
import React from 'react'
|
|
import hoistNonReactStatics from 'hoist-non-react-statics'
|
|
import I18nContext from './i18n-context'
|
|
|
|
// higher order decorator for components that need `t`
|
|
export default function translate() {
|
|
return WrappedComponent => {
|
|
const _translate = props => (
|
|
<I18nContext.Consumer>
|
|
{t => <WrappedComponent {...props} t={t} />}
|
|
</I18nContext.Consumer>
|
|
)
|
|
|
|
return hoistNonReactStatics(_translate, WrappedComponent)
|
|
}
|
|
}
|