mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2026-04-24 14:00:57 +02:00
30 lines
661 B
JavaScript
30 lines
661 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { IntlContext } from 'react-intl';
|
|
|
|
/**
|
|
* Publishes the react-intl v3 IntlContext value into the legacy React
|
|
* childContextTypes API so that class components accessing this.context.intl
|
|
* continue to work without modification.
|
|
*/
|
|
class IntlBridge extends React.Component {
|
|
static propTypes = {
|
|
children: PropTypes.node.isRequired,
|
|
};
|
|
|
|
static contextType = IntlContext;
|
|
|
|
static childContextTypes = {
|
|
intl: PropTypes.object,
|
|
};
|
|
|
|
getChildContext() {
|
|
return { intl: this.context };
|
|
}
|
|
|
|
render() {
|
|
return this.props.children;
|
|
}
|
|
}
|
|
|
|
export default IntlBridge;
|