JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10574
  • Score
    100M100P100Q133512F
  • License MIT

Provides utilities to check if ad block is enabled on a page via both a React hook and a wrapper component.

Package Exports

  • adblock-detect-react

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (adblock-detect-react) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

adblock-detect-react

npm version Publish Status

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 "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 "adblock-detect-react";

const SomeFunctionalComponent = () => {
  return (
    <AdBlockDetectedWrapper>
      <div>{"Hello Ad Blocked Page"}</div>
    </AdBlockDetectedWrapper>
  );
};