最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Manage the entire body in reactjs - Stack Overflow

programmeradmin4浏览0评论

I have a react ponent manages the entire app in react. It looks like:

var Page = React.createClass({
    displayName: 'Page',

    render: function() {
        return (
            React.DOM.div(null
                /*, stuff here ..*/
            )
        );
    }
});

And html looks like

<body id="content"></body>

And I render it like:

React.renderComponent(Page(null), document.getElementById('content'));

But instead, I would like react to manage the entire body tag, so there is no redundant nested div. How can I render such a thing?

I have a react ponent manages the entire app in react. It looks like:

var Page = React.createClass({
    displayName: 'Page',

    render: function() {
        return (
            React.DOM.div(null
                /*, stuff here ..*/
            )
        );
    }
});

And html looks like

<body id="content"></body>

And I render it like:

React.renderComponent(Page(null), document.getElementById('content'));

But instead, I would like react to manage the entire body tag, so there is no redundant nested div. How can I render such a thing?

Share Improve this question asked Jan 13, 2014 at 22:29 HepticHeptic 3,1064 gold badges33 silver badges53 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 17

I'm not pletely sure if this is what you're asking, but you can run

React.renderComponent(Page(null), document.body);

to mount a ponent directly into body.

发布评论

评论列表(0)

  1. 暂无评论