如何操作子对象的渲染输出
本文介绍了如何操作子对象的渲染输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用来自第三方库的组件,并且我想操作呈现输出。
假设我们有两个组件:
// third party component that I don't have access to its code
const ThirdPartyComponent = () => (
<div>
<span>
...
</span>
</div>
)
// My component using the third party component
const MyComponent = () => (
<div className="wrapper">
<ThirdPartyComponent />
</div>
)
通常输出为:
<div class="wrapper">
<div>
<span>
...
</span>
</div>
</div>
现在我要操作第三方组件,使我的组件呈现以下内容:
<div class="wrapper">
<span>
...
</span>
</div>
或换句话说从不需要的<div />
元素中解开呈现的内容。
1.我无法更改第三方代码
2.子组件不转发ref
您知道怎么做吗?