Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React.renderComponentToString failing case when component children is a function #860

Closed
swannodette opened this issue Jan 10, 2014 · 15 comments

Comments

@swannodette
Copy link

var Hello = React.createClass({
    componentDidMount: function() {},
    render: function() {
        return this.props.children();
    }
});

React.renderComponentToString(
    Hello(null, function() { return React.DOM.div(null, "Hello"); }), 
    function(s) { console.log(s); }
);

Results in:

Uncaught TypeError: Cannot read property 'firstChild' of undefined 
@vjeux
Copy link
Contributor

vjeux commented Jan 10, 2014

JSFiddle: http://jsfiddle.net/vjeux/E8gCL/

@vjeux
Copy link
Contributor

vjeux commented Jan 10, 2014

Reduced to

var Hello = React.createClass({
    render: function() {
        return this.props.children;
    }
});

React.renderComponentToString(
    Hello(null, React.DOM.div(null, "Hello")), 
    function(s) { console.log(s); }
);

http://jsfiddle.net/vjeux/E8gCL/1/

@sophiebits
Copy link
Collaborator

@vjeux Your last fiddle doesn't repro the problem for me; the componentDidMount is significant.

@vjeux
Copy link
Contributor

vjeux commented Jan 10, 2014

@spicyj : Woops you are right, I rushed the comment :( http://jsfiddle.net/vjeux/E8gCL/2/

@plievone
Copy link
Contributor

Breaks on 0.8.0 on browser only, but not on master for me. (Noticed the breaking with componentDidMount some time ago but didn't file an issue as perhaps there had been an issue already)

@petehunt
Copy link
Contributor

I have a fix for this

@plievone
Copy link
Contributor

@petehunt But those fiddles seem to work ok on current master?

@petehunt
Copy link
Contributor

The fix is for the somewhat related putListener() memory leak

@sophiebits
Copy link
Collaborator

I believe this was fixed by e73900d.

@swannodette
Copy link
Author

I haven't had a chance to verify myself but according to an Om user this issue is still not fixed. omcljs/om#47, they tested with a recent React commit 4974734

@sophiebits
Copy link
Collaborator

Well, http://jsfiddle.net/E8gCL/4/ works for me now.

@sophiebits
Copy link
Collaborator

(Filed #1079 which is probably the underlying cause even though the symptoms here changed.)

@swannodette
Copy link
Author

I've confirmed that this is no longer a problem in Om w/ React master.

@sophiebits
Copy link
Collaborator

@swannodette This works for you?

(.renderComponentToString js/React (dom/input nil))

@swannodette
Copy link
Author

@spicyj actually that does not work. But the custom component cases work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants