javascript - 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.
解决方案
也许你应该在 RComponent 的 render 方法中添加一些这样的结构
<View>{props.children}</View>
推荐阅读
- erlang - 启动 ejabberd 集群的问题
- java - 即使我已将它们添加到库中,我也无法导入 java.sql 类
- node.js - Node.js 中的 JSON.stringify
- python-3.x - 在 AWS Elastic Beanstalk 上部署破折号可视化仪表板时出错
- javascript - 将鼠标悬停在内容上时,在工具提示中显示图像会给我一个闪烁的效果
- google-sheets - 将 SUM 行和 SUM 列添加到 Google 表格中的查询
- docker - 使用 fluentd 从 jorunald 中过滤掉容器日志
- javascript - Promise 的创建是同步的吗?
- text-files - 读取 txt 文件 JSON 数据以在 Cloud Pub Sub 中发布消息
- php - 如何显示 id 等于 1,2,3,4 的所有记录