2015-11-05 91 views
1

我想使用React渲染一个<section>元素,但只有在满足某些条件的情况下。是否有可能用React替换DOM元素?

问题是我不能嵌套一个<div><section>所以除了<body>最高级别的DOM元素是<section>

我的HTML:

<section id="my_element"></section> 

我的阵营:

ReactDOM.render(
    <div className="container"> 
    ... 
    </div>, 
    document.getElementById('my_element') 
); 

我知道Angular指令可以用你的渲染元素替换原来的DOM元素nt通过使用replace: true

app.directive('myElement', function(){ 
    return { 
    replace: true, 
    ... 
    } 
    }; 
}); 

在React中有类似的东西吗?

+0

http://stackoverflow.com/questions/30686796/react-render-replace-container-instead-of-inserting-into – user120242

回答

相关问题