Demo.js
export const AdBlockDemo = (props) => {
function adBlockNotDetected() {
alert('AdBlock is not enabled');
}
function adBlockDetected() {
alert('AdBlock is enabled');
}
useEffect(()=>{
if(typeof blockAdBlock === 'undefined') {
adBlockDetected();
} else {
blockAdBlock.onDetected(adBlockDetected);
blockAdBlock.onNotDetected(adBlockNotDetected);
},[]);
}
I have installed blockadblock (3.2.1) on my project. when I try to use the instance of BlockAdBlock which is instantiated automatically then the following error has occurred.
'BlockAdBlock' is not defined no-undef
I tried to create an instance manually after adding scripts and the same error occurs again
<script>var blockAdBlock = false;</script>
<script src="./blockadblock.js"></script>
var blockAdBlock = new BlockAdBlock({
checkOnLoad: true,
resetOnEnd: true
});