1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-09 01:45:03 +00:00
mon-entreprise/source/components/withLanguage.js
Johan Girod 7ab7c6c7eb 🎨 Format the currencies depending on the locale
Add a withLanguage HOC for abstracting the language
implementation
2018-05-09 11:24:01 +02:00

20 lines
470 B
JavaScript

import React, { Component } from 'react'
import PropTypes from 'prop-types'
export default function withLanguage(WrappedComponent) {
return class WithLanguage extends Component {
static contextTypes = {
i18n: PropTypes.object.isRequired
}
static displayName = `withLanguage(${Component.displayName ||
Component.name})`
render() {
return (
<WrappedComponent
{...this.props}
language={this.context.i18n.language + ''}
/>
)
}
}
}