[fix] error in setNativeProps when no style

Close #325
Close #327
This commit is contained in:
Nicolas Gallagher
2017-01-10 17:28:39 -08:00
parent b14d2e5bd8
commit 65febbbc52
2 changed files with 6 additions and 4 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
import applyLayout from '../../modules/applyLayout'; import applyLayout from '../../modules/applyLayout';
import applyNativeMethods from '../../modules/applyNativeMethods'; import applyNativeMethods from '../../modules/applyNativeMethods';
import NativeMethodsMixin from '../../modules/NativeMethodsMixin';
import createDOMElement from '../../modules/createDOMElement'; import createDOMElement from '../../modules/createDOMElement';
import findNodeHandle from '../../modules/findNodeHandle'; import findNodeHandle from '../../modules/findNodeHandle';
import StyleSheet from '../../apis/StyleSheet'; import StyleSheet from '../../apis/StyleSheet';
import Text from '../Text'; import Text from '../Text';
import TextareaAutosize from 'react-textarea-autosize'; import TextareaAutosize from 'react-textarea-autosize';
import TextInputState from './TextInputState'; import TextInputState from './TextInputState';
import UIManager from '../../apis/UIManager';
import View from '../View'; import View from '../View';
import { Component, PropTypes } from 'react'; import { Component, PropTypes } from 'react';
@@ -116,7 +116,7 @@ class TextInput extends Component {
} }
setNativeProps(props) { setNativeProps(props) {
UIManager.updateView(this._node, props, this); NativeMethodsMixin.setNativeProps.call(this, props);
} }
componentDidMount() { componentDidMount() {
+4 -2
View File
@@ -10,6 +10,7 @@ import findNodeHandle from '../findNodeHandle';
import StyleRegistry from '../../apis/StyleSheet/registry'; import StyleRegistry from '../../apis/StyleSheet/registry';
import UIManager from '../../apis/UIManager'; import UIManager from '../../apis/UIManager';
const emptyObject = {};
const REGEX_CLASSNAME_SPLIT = /\s+/; const REGEX_CLASSNAME_SPLIT = /\s+/;
const REGEX_STYLE_PROP = /rn-(.*):.*/; const REGEX_STYLE_PROP = /rn-(.*):.*/;
@@ -83,7 +84,7 @@ const NativeMethodsMixin = {
const domClassList = [ ...node.classList ]; const domClassList = [ ...node.classList ];
// Resolved state // Resolved state
const resolvedProps = StyleRegistry.resolve(nativeProps.style); const resolvedProps = StyleRegistry.resolve(nativeProps.style) || emptyObject;
const resolvedClassList = classNameToList(resolvedProps.className); const resolvedClassList = classNameToList(resolvedProps.className);
// Merged state // Merged state
@@ -94,7 +95,8 @@ const NativeMethodsMixin = {
// Only pass on a class name when the style is unchanged. // Only pass on a class name when the style is unchanged.
domClassList.forEach((c) => { domClassList.forEach((c) => {
const prop = getStyleProp(c); const prop = getStyleProp(c);
if (resolvedProps.className.indexOf(prop) === -1) { const className = resolvedProps.className;
if (!className || className.indexOf(prop) === -1) {
classList.push(c); classList.push(c);
} }
}); });