react-google-adsense
v0.0.5
Published
A simple ReactJS component for displaying Google AdSense advertisements
Downloads
105
Maintainers
Readme
react-google-adsense
A simple ReactJS component for displaying Google AdSense adverts. The component's render()
method returns the <ins>
element containing the advert, and the componentWillMount()
method handles injecting and loading the Google Adsense SDK.
Usage
npm install --save react-google-adsense
to install the module locally.
improt React, { Component } from 'react';
import ReactGoogleAdsense from 'react-google-adsense';
export default class MyComponent extends Component {
render() {
const adSenseClientId = 'abcdef';
const adSenseSlotId = 'ghijkl';
return (
<ReactGoogleAdsense
client={adSenseClientId}
slot={adSenseSlotId}
>
);
}
}
Other (optional) props that can be passed to the component are:
- format: ad format. Defaults to
auto
.- See this page for further info on formats.
- className: css class to apply to the DOM element.
- style: an object containing CSS styles to apply to the DOM element. Defaults to
{ display: block }
.