zent
Version:
一套前端设计语言和基于React的实现
24 lines (23 loc) • 797 B
JavaScript
import { __extends } from "tslib";
import { Component } from 'react';
import I18nContext from './I18nContext';
var I18nReceiver = (function (_super) {
__extends(I18nReceiver, _super);
function I18nReceiver() {
return _super !== null && _super.apply(this, arguments) || this;
}
I18nReceiver.prototype.receive = function () {
var componentName = this.props.componentName;
var i18n = this.context[componentName];
return (typeof i18n === 'function'
? i18n()
: i18n);
};
I18nReceiver.prototype.render = function () {
var children = this.props.children;
return children(this.receive());
};
I18nReceiver.contextType = I18nContext;
return I18nReceiver;
}(Component));
export default I18nReceiver;