首页 > 解决方案 > Wrap div not rendering in React

问题描述

I have a render() function that returns a div with content inside of it, such as:

return(
    <div style={{background: "black"}}>
        <[ReactComponent]>
            <[AnotherReactComponent]>
                ...
            </[AnotherReactComponent]>
        </[ReactComponent]>
    </div>
);

When I inspect the element, the outer div does not render, however the ReactComponent does.

标签: javascripthtmlcssreactjsreact-native

解决方案


也许你应该在 RComponent 的 render 方法中添加一些这样的结构

<View>{props.children}</View>

推荐阅读