Skip to content

Commit

Permalink
fix: switch back to useLayoutEffect in AdvertisingSlot (#122)
Browse files Browse the repository at this point in the history
## Description
Following the feedback from @jesperzach and further investigation into
the consequences of PR
#105, we've decided to
revert back to using `useLayoutEffect` in the `AdvertisingSlot`
component.

Co-authored-by: Stephen Gill <stephen.gill@adevinta.com>
  • Loading branch information
caffeinated-pixels and Stephen Gill committed Mar 16, 2023
1 parent 5e68f7e commit 414f55f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/AdvertisingSlot.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PropTypes from 'prop-types';
import React, { useEffect, useRef, useContext } from 'react';
import React, { useLayoutEffect, useRef, useContext } from 'react';
import AdvertisingContext from '../AdvertisingContext';
import calculateRootMargin from './utils/calculateRootMargin';
import isLazyLoading from './utils/isLazyLoading';
Expand All @@ -18,7 +18,7 @@ function AdvertisingSlot({
const { activate, config } = useContext(AdvertisingContext);
const lazyLoadConfig = getLazyLoadConfig(config, id);
const isLazyLoadEnabled = isLazyLoading(lazyLoadConfig);
useEffect(() => {
useLayoutEffect(() => {
if (!config || !isLazyLoadEnabled) {
return () => {};
}
Expand All @@ -42,7 +42,7 @@ function AdvertisingSlot({
};
}, [activate, config]);

useEffect(() => {
useLayoutEffect(() => {
if (!config || isLazyLoadEnabled) {
return;
}
Expand Down

0 comments on commit 414f55f

Please sign in to comment.