Skip to content

Commit

Permalink
more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jun 26, 2023
1 parent 1e468b4 commit 9192f6b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions docs/src/modules/components/AdCarbon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@ const CarbonRoot = styled('span')(({ theme }) => {
const styles = adStylesObject['body-image'](theme);

return {
'& > div': {
// The isolation logic of carbonads is broken.
// Once the script starts loading, it will asynchronous resolve, with no way to stop it.
// This leads to duplication of the ad.
//
// To solve the issue, we only display the #carbonads div
display: 'none',
},
'& #carbonads': {
display: 'block',
...styles.root,
'& .carbon-img': styles.imgWrapper,
'& img': styles.img,
'& a, & a:hover': styles.a,
'& .carbon-text': styles.description,
'& .carbon-poweredby': styles.poweredby,
},
'& [id^=carbonads_]': {
display: 'none',
},
};
});

Expand All @@ -28,7 +34,9 @@ function AdCarbonImage() {
React.useEffect(() => {
// The isolation logic of carbonads is broken.
// Once the script starts loading, it will asynchronous resolve, with no way to stop it.
// This leads to duplication of the ad. To solve the issue, we debounce the load action.
// This leads to duplication of the ad.
//
// To solve the issue, e.g. StrictModel double effect execution, we debounce the load action.
const load = setTimeout(() => {
const script = loadScript(
'https://cdn.carbonads.com/carbon.js?serve=CKYIL27L&placement=material-uicom',
Expand Down

0 comments on commit 9192f6b

Please sign in to comment.