Skip to content

Commit 85aaa39

Browse files
lyahdavnecolas
authored andcommitted
[fix] i18n of styles when using 'setNativeProps'
Close #732
1 parent b85a706 commit 85aaa39

File tree

2 files changed

+11
-3
lines changed
  • packages/react-native-web/src

2 files changed

+11
-3
lines changed

packages/react-native-web/src/components/View/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class View extends Component<ViewProps> {
6565
if (hitSlop) {
6666
const hitSlopStyle = calculateHitSlopStyle(hitSlop);
6767
const hitSlopChild = createElement('span', { style: [styles.hitSlop, hitSlopStyle] });
68-
otherProps.children = React.Children.toArray([ hitSlopChild, otherProps.children ]);
68+
otherProps.children = React.Children.toArray([hitSlopChild, otherProps.children]);
6969
}
7070

7171
return createElement('div', otherProps);

packages/react-native-web/src/modules/NativeMethodsMixin/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ const NativeMethodsMixin = {
102102
* the initial styles from the DOM node and merge them with incoming props.
103103
*/
104104
setNativeProps(nativeProps: Object) {
105+
if (!nativeProps) {
106+
return;
107+
}
108+
105109
// Copy of existing DOM state
106110
const node = findNodeHandle(this);
107111
const nodeStyle = node.style;
@@ -117,10 +121,14 @@ const NativeMethodsMixin = {
117121
style[toCamelCase(property)] = nodeStyle.getPropertyValue(property);
118122
}
119123
}
120-
const domStyleProps = { classList, style };
121124

125+
const domStyleProps = { classList, style };
126+
const props = {
127+
...nativeProps,
128+
style: i18nStyle(nativeProps.style)
129+
};
122130
// Next DOM state
123-
const domProps = createDOMProps(null, i18nStyle(nativeProps), style =>
131+
const domProps = createDOMProps(null, props, style =>
124132
StyleRegistry.resolveStateful(style, domStyleProps, { i18n: false })
125133
);
126134
UIManager.updateView(node, domProps, this);

0 commit comments

Comments
 (0)