@renfei/adblock-detect-react
v1.1.2
Published
Provides utilities to check if ad block is enabled on a page via both a React hook and a wrapper component.
Downloads
97
Maintainers
Readme
adblock-detect-react
Description
Provides utilities to check if ad block is enabled on a page via either a React hook or a wrapper component.
Example Usage
useDetectAdBlock hook
import React from "react";
import { useDetectAdBlock } from "@renfei/adblock-detect-react";
const SomeFunctionalComponent = () => {
const adBlockDetected = useDetectAdBlock();
React.useEffect(() => {
if (adBlockDetected) {
window.alert("ad block detected");
}
}, []);
return <div>{adBlockDetected && "Hello Ad Blocked Page"}</div>;
};
AdBlockDetectedWrapper component
import React from "react";
import { AdBlockDetectedWrapper } from "@renfei/adblock-detect-react";
const SomeFunctionalComponent = () => {
return (
<AdBlockDetectedWrapper>
<div>{"Hello Ad Blocked Page"}</div>
</AdBlockDetectedWrapper>
);
};