Skip to content

Invoking renderToStaticMarkup in render() causes refs to break #3344

@masonicboom

Description

@masonicboom

Demonstrated at http://jsfiddle.net/xnhzvdoa/1/; open the error console and you should see this:

Uncaught Error: Invariant Violation: addComponentAsRefTo(...): Only a ReactOwner can have refs. This usually means that you're trying to add a ref to a component that doesn't have an owner (that is, was not created inside of another component's `render` method). Try rendering this component inside of a new top-level component which will hold the ref.

var Bug = React.createClass({
    render: function() {
        var html = React.renderToStaticMarkup(React.DOM.img());
        return React.DOM.div({ ref: 'ref' }, html);
    }
});
Bug = React.createFactory(Bug);

React.render(Bug(), document.body);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions