Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import React, { Component } from 'react';
  2.  
  3. class AdBlockerDetection extends Component{
  4.  
  5. state = {
  6. usingAdBlock : false,
  7. }
  8.  
  9. componentDidMount(){
  10. this.setState ({
  11. usingAdBlock: this.fakeAdBanner.offsetHeight === 0
  12. });
  13. }
  14.  
  15. render(){
  16. if(this.state.usingAdBlock === true) {
  17. return this.props.children;
  18. }
  19. return(
  20. <div
  21. ref={r =>(this.fakeAdBanner = r)}
  22. style={{
  23. height: '1px',
  24. width: '1px',
  25. visibility: 'none',
  26. pointerEvents: 'none'
  27. }}
  28. className='adBanner'
  29. />
  30. );
  31. }
  32. }
  33.  
  34. export default AdBlockerDetection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement