Skip to content

Commit

Permalink
Allow object as textarea child
Browse files Browse the repository at this point in the history
Preserves Stack behavior. There's already a warning for this.
  • Loading branch information
acdlite committed Jan 31, 2017
1 parent 802c820 commit 7af673a
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions src/renderers/shared/fiber/ReactChildFiber.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,34 +110,36 @@ function coerceRef(current: ?Fiber, element: ReactElement) {
}

function throwOnInvalidObjectType(returnFiber : Fiber, newChild : Object) {
const childrenString = String(newChild);
let addendum = '';
if (__DEV__) {
addendum =
' If you meant to render a collection of children, use an array ' +
'instead or wrap the object using createFragment(object) from the ' +
'React add-ons.';
if (newChild._isReactElement) {
if (returnFiber.type !== 'textarea') {
const childrenString = String(newChild);
let addendum = '';
if (__DEV__) {
addendum =
' It looks like you\'re using an element created by a different ' +
'version of React. Make sure to use only one copy of React.';
}
const owner = ReactCurrentOwner.owner || returnFiber._debugOwner;
if (owner && typeof owner.tag === 'number') {
const name = getComponentName((owner : any));
if (name) {
addendum += ' Check the render method of `' + name + '`.';
' If you meant to render a collection of children, use an array ' +
'instead or wrap the object using createFragment(object) from the ' +
'React add-ons.';
if (newChild._isReactElement) {
addendum =
' It looks like you\'re using an element created by a different ' +
'version of React. Make sure to use only one copy of React.';
}
const owner = ReactCurrentOwner.owner || returnFiber._debugOwner;
if (owner && typeof owner.tag === 'number') {
const name = getComponentName((owner : any));
if (name) {
addendum += ' Check the render method of `' + name + '`.';
}
}
}
invariant(
false,
'Objects are not valid as a React child (found: %s).%s',
childrenString === '[object Object]' ?
'object with keys {' + Object.keys(newChild).join(', ') + '}' :
childrenString,
addendum
);
}
invariant(
false,
'Objects are not valid as a React child (found: %s).%s',
childrenString === '[object Object]' ?
'object with keys {' + Object.keys(newChild).join(', ') + '}' :
childrenString,
addendum
);
}

// This wrapper function exists because I expect to clone the code in each path
Expand Down

0 comments on commit 7af673a

Please sign in to comment.