Skip to content

Shallow rendering won't render primitive nodes in 0.14 #4721

Closed
@glenjamin

Description

@glenjamin

This might be intentional, but it's technically a breaking change, so I figured I'd report it.

The following script:

var React = require('react');
var TestUtils;
if (React.version.substring(4) == '0.13') {
  TestUtils = require('react/addons').addons.TestUtils;
} else {
  TestUtils = require('react-addons-test-utils');
}

var renderer = TestUtils.createRenderer();

renderer.render(
  React.createElement('h1', {}, 'Hello')
);

console.log(renderer.getRenderOutput());

Under 0.13

> node sample.js
{ type: 'h1',
  key: null,
  ref: null,
  _owner: null,
  _context: null,
  _store:
   { props: { children: 'Hello' },
     originalProps: { children: 'Hello' } } }

Under 0.14

> node sample.js
/myapp/node_modules/react/lib/ReactCompositeComponent.js:129
    var inst = new Component(publicProps, publicContext, ReactUpdateQueue);
               ^
TypeError: string is not a function
    at ReactCompositeComponentMixin.mountComponent (/myapp/node_modules/react/lib/ReactCompositeComponent.js:129:16)
    at wrapper [as mountComponent] (/myapp/node_modules/react/lib/ReactPerf.js:66:21)
    at ReactShallowRenderer._render (/myapp/node_modules/react/lib/ReactTestUtils.js:347:14)
    at ReactShallowRenderer.render (/myapp/node_modules/react/lib/ReactTestUtils.js:329:8)
    at Object.<anonymous> (/myapp/sample.js:11:10)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions