@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
21 lines (18 loc) • 922 B
JavaScript
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from "react";
import { pureTranslate } from "../Translate";
import DictionaryContext from "./DictionaryContext";
const Dictionary = ({
values,
children
}) => React.createElement(DictionaryContext.Provider, {
value: values
}, children);
export function withDictionary(Component) {
return function DictionaryComponent(props) {
return React.createElement(DictionaryContext.Consumer, null, dictionary => React.createElement(Component, _extends({}, props, {
translate: (tKey, values) => pureTranslate(dictionary, tKey, values)
})));
};
}
export default Dictionary;