Skip to content

Commit

Permalink
Hotfix 1.1.1: Handle SSR
Browse files Browse the repository at this point in the history
  • Loading branch information
Saigredan committed Mar 4, 2021
1 parent 69dae40 commit 3507e06
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ In addition to above spec use `Action` group to gather all needed actions requir

## Unreleased

## [1.1.0] - 2021-01-12 Production

### Added
- Lazy load feature

## [1.0.0] - 2021-01-12 Production

### Added
- AdManagerProvider component
- AdManagerSlot component
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yieldbird_gpt_components",
"version": "1.1.0",
"version": "1.1.1",
"description": "Made with create-react-library",
"author": "YieldbirdDev",
"license": "MIT",
Expand Down
10 changes: 7 additions & 3 deletions src/Context/AdManagerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export const AdManagerProvider: React.FC<Props> = ({
const actionEntries = entries.filter((entry) => entry.isIntersecting)

if (actionEntries.length > 0) {
window &&
typeof window !== 'undefined' &&
window.googletag.cmd.push(() => {
const displayEntries = actionEntries.map((entry) => ({
slot:
window &&
typeof window !== 'undefined' &&
window.googletag
.pubads()
.getSlots()
Expand All @@ -48,7 +48,11 @@ export const AdManagerProvider: React.FC<Props> = ({
}))

displayEntries.forEach((element) => {
if (window && window.googletag && element.slot) {
if (
typeof window !== 'undefined' &&
window.googletag &&
element.slot
) {
window.googletag.display(element.slot.getSlotElementId())
window.googletag.pubads().refresh([element.slot])
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/intersectionObserver.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export function isIntersectionObserverAvailable() {
return window && 'IntersectionObserver' in window
return typeof window !== 'undefined' && 'IntersectionObserver' in window
}

0 comments on commit 3507e06

Please sign in to comment.