@samitouri / QOS-React / commits / 7af673afc1

Allow object as textarea child

Preserves Stack behavior. There's already a warning for this.

Andrew Clark committed Jan 30, 2017 at 12:21 UTC 7af673afc148fe2eb8a1753a901c1d46b78ea476
1 file changed +26 -24
src/renderers/shared/fiber/ReactChildFiber.js
+26 -24
@@ -110,34 +110,36 @@ function coerceRef(current: ?Fiber, element: ReactElement) {
110 }
111
112 function throwOnInvalidObjectType(returnFiber : Fiber, newChild : Object) {
113 - const childrenString = String(newChild);
114 - let addendum = '';
115 - if (__DEV__) {
116 - addendum =
117 - ' If you meant to render a collection of children, use an array ' +
118 - 'instead or wrap the object using createFragment(object) from the ' +
119 - 'React add-ons.';
120 - if (newChild._isReactElement) {
113 + if (returnFiber.type !== 'textarea') {
114 + const childrenString = String(newChild);
115 + let addendum = '';
116 + if (__DEV__) {
117 addendum =
122 - ' It looks like you\'re using an element created by a different ' +
123 - 'version of React. Make sure to use only one copy of React.';
124 - }
125 - const owner = ReactCurrentOwner.owner || returnFiber._debugOwner;
126 - if (owner && typeof owner.tag === 'number') {
127 - const name = getComponentName((owner : any));
128 - if (name) {
129 - addendum += ' Check the render method of `' + name + '`.';
118 + ' If you meant to render a collection of children, use an array ' +
119 + 'instead or wrap the object using createFragment(object) from the ' +
120 + 'React add-ons.';
121 + if (newChild._isReactElement) {
122 + addendum =
123 + ' It looks like you\'re using an element created by a different ' +
124 + 'version of React. Make sure to use only one copy of React.';
125 + }
126 + const owner = ReactCurrentOwner.owner || returnFiber._debugOwner;
127 + if (owner && typeof owner.tag === 'number') {
128 + const name = getComponentName((owner : any));
129 + if (name) {
130 + addendum += ' Check the render method of `' + name + '`.';
131 + }
132 }
133 }
134 + invariant(
135 + false,
136 + 'Objects are not valid as a React child (found: %s).%s',
137 + childrenString === '[object Object]' ?
138 + 'object with keys {' + Object.keys(newChild).join(', ') + '}' :
139 + childrenString,
140 + addendum
141 + );
142 }
133 - invariant(
134 - false,
135 - 'Objects are not valid as a React child (found: %s).%s',
136 - childrenString === '[object Object]' ?
137 - 'object with keys {' + Object.keys(newChild).join(', ') + '}' :
138 - childrenString,
139 - addendum
140 - );
143 }
144
145 // This wrapper function exists because I expect to clone the code in each path