[fix] i18n of styles when using 'setNativeProps'

Close #732
This commit is contained in:
Liron Yahdav
2017-12-30 14:18:55 -08:00
committed by Nicolas Gallagher
parent b85a7062be
commit 85aaa39206
2 changed files with 11 additions and 3 deletions

View File

@@ -65,7 +65,7 @@ class View extends Component<ViewProps> {
if (hitSlop) {
const hitSlopStyle = calculateHitSlopStyle(hitSlop);
const hitSlopChild = createElement('span', { style: [styles.hitSlop, hitSlopStyle] });
otherProps.children = React.Children.toArray([ hitSlopChild, otherProps.children ]);
otherProps.children = React.Children.toArray([hitSlopChild, otherProps.children]);
}
return createElement('div', otherProps);

View File

@@ -102,6 +102,10 @@ const NativeMethodsMixin = {
* the initial styles from the DOM node and merge them with incoming props.
*/
setNativeProps(nativeProps: Object) {
if (!nativeProps) {
return;
}
// Copy of existing DOM state
const node = findNodeHandle(this);
const nodeStyle = node.style;
@@ -117,10 +121,14 @@ const NativeMethodsMixin = {
style[toCamelCase(property)] = nodeStyle.getPropertyValue(property);
}
}
const domStyleProps = { classList, style };
const domStyleProps = { classList, style };
const props = {
...nativeProps,
style: i18nStyle(nativeProps.style)
};
// Next DOM state
const domProps = createDOMProps(null, i18nStyle(nativeProps), style =>
const domProps = createDOMProps(null, props, style =>
StyleRegistry.resolveStateful(style, domStyleProps, { i18n: false })
);
UIManager.updateView(node, domProps, this);