Overview
The Freestar React component has hooks that trigger when an ad slot's behavior or status changes.
onNewAdSlotsHook
The onNewAdSlotsHook event hook accepts a callback function. It returns the placementName once the component mounts and an ad is requested.
JSX
import React, { Component } from 'react'
import FreestarAdSlot from '@freestar/pubfig-adslot-react-component'
class onNewAdSlotsHookDemo extends Component {
render() {
const publisher = 'yourdomain-com'
const placementName = 'yourdomaincom-placementName'
return (
<div>
<FreestarAdSlot
publisher={publisher}
placementName={placementName}
onNewAdSlotsHook={
function newAdSlotCreated(placementName) {
console.log('creating ad', placementName)
}
}
/>
</div>
)
}
}
export default onNewAdSlotsHookDemo
onDeleteAdSlotsHook
The onDeleteAdSlotsHook event hook accepts a callback function. It returns the placementName once the component unmounts.
JSX
import React, { Component } from 'react'
import FreestarAdSlot from '@freestar/pubfig-adslot-react-component'
class onDeleteAdSlotsHookDemo extends Component {
render() {
const publisher = 'yourdomain-com'
const placementName = 'yourdomaincom-placementName'
return (
<div>
<FreestarAdSlot
publisher={publisher}
placementName={placementName}
onDeleteAdSlotsHook={
function adSlotDeleted(placementName) {
console.log('deleting ad', placementName)
}
}
/>
</div>
)
}
}
export default onDeleteAdSlotsHookDemo
onAdRefreshHook
The onAdRefreshHook event hook accepts a callback function. It returns the placementName once the component refreshes an ad.
JSX
import React, { Component } from 'react'
import FreestarAdSlot from '@freestar/pubfig-adslot-react-component'
class onAdRefreshHookDemo extends Component {
render() {
const publisher = 'yourdomain-com'
const placementName = 'yourdomaincom-placementName'
return (
<div>
<FreestarAdSlot
publisher={publisher}
placementName={placementName}
onAdRefreshHookHook={
function adSlotRefreshed(placementName) {
console.log('refreshing ad', placementName)
}
}
/>
</div>
)
}
}
export default onAdRefreshHookDemo