1
我有一個組件需要根據應用程序的狀態加載更改Pinterest嵌入。 Pinterest嵌入由一個<a>
標籤組成,通過使用我的HTML底部的異步腳本(可用here)將其轉換爲<span>
標籤內的複雜佈局。但是,我很難弄清楚如何通過使用更新後的道具進行重新渲染來清除嵌入的舊<span>
並重新運行腳本以呈現新的嵌入。謝謝!正在更新Pinterest嵌入Preact App
我的組件:
const PinterestEmbed = ({ location, size }) => (
<div stye="text-align: center;margin: auto;">
<a
data-pin-do="embedPin"
data-pin-width={size}
href={location}>
Pin via Pinterest
</a>
</div>
);
export default PinterestEmbed;