Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- class AdBlockerDetection extends Component{
- state = {
- usingAdBlock : false,
- }
- componentDidMount(){
- this.setState ({
- usingAdBlock: this.fakeAdBanner.offsetHeight === 0
- });
- }
- render(){
- if(this.state.usingAdBlock === true) {
- return this.props.children;
- }
- return(
- <div
- ref={r =>(this.fakeAdBanner = r)}
- style={{
- height: '1px',
- width: '1px',
- visibility: 'none',
- pointerEvents: 'none'
- }}
- className='adBanner'
- />
- );
- }
- }
- export default AdBlockerDetection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement