UNPKG

react-translate-maker

Version:

React translation module. Internationalize your great project.

30 lines (24 loc) 671 B
import { isValidElement, cloneElement, Children } from 'react'; function replaceReactChildren(children, value) { if (!isValidElement(children)) { return children; } return Children.map(children, child => { if (!isValidElement(child)) { return child; } const { props } = child; if (props && props.children === '#') { return cloneElement(child, { children: value }); } return replaceReactChildren(child, value); }); } export default function children(value, part, attrs, metadata, newChildrenValue) { return replaceReactChildren(value, newChildrenValue); } //# sourceMappingURL=children.js.map