diff --git a/src/components/View/__tests__/index-test.js b/src/components/View/__tests__/index-test.js
index ef774148..92252606 100644
--- a/src/components/View/__tests__/index-test.js
+++ b/src/components/View/__tests__/index-test.js
@@ -13,9 +13,20 @@ describe('components/View', () => {
});
describe('prop "children"', () => {
- test('text node throws error', () => {
- const children = 'hello';
- const render = () => shallow({children});
+ test('text node throws error (single)', () => {
+ const render = () => shallow('hello');
+ expect(render).toThrow();
+ });
+
+ test('text node throws error (array)', () => {
+ const render = () =>
+ shallow(
+
+
+ 'hello'
+
+
+ );
expect(render).toThrow();
});
diff --git a/src/components/View/index.js b/src/components/View/index.js
index a8482fbb..17c0c532 100644
--- a/src/components/View/index.js
+++ b/src/components/View/index.js
@@ -51,10 +51,9 @@ class View extends Component {
} = this.props;
if (process.env.NODE_ENV !== 'production') {
- invariant(
- typeof this.props.children !== 'string',
- 'A text node cannot be a child of a '
- );
+ React.Children.toArray(this.props.children).forEach(item => {
+ invariant(typeof item !== 'string', 'A text node cannot be a child of a ');
+ });
}
const { isInAParentText } = this.context;
diff --git a/src/modules/normalizeNativeEvent/__tests__/index-test.js b/src/modules/normalizeNativeEvent/__tests__/index-test.js
index de07ff87..4f7aea59 100644
--- a/src/modules/normalizeNativeEvent/__tests__/index-test.js
+++ b/src/modules/normalizeNativeEvent/__tests__/index-test.js
@@ -2,7 +2,7 @@
import normalizeNativeEvent from '..';
-const normalizeEvent = (nativeEvent) => {
+const normalizeEvent = nativeEvent => {
const result = normalizeNativeEvent(nativeEvent);
result.timestamp = 1496876171255;
if (result.changedTouches && result.changedTouches[0]) {
@@ -12,7 +12,7 @@ const normalizeEvent = (nativeEvent) => {
result.touches[0].timestamp = 1496876171255;
}
return result;
-}
+};
describe('modules/normalizeNativeEvent', () => {
describe('mouse events', () => {