react-adsense
Version:
A Simple React component for Google AdSense and Baidu advertisement.
86 lines (62 loc) • 1.88 kB
Markdown
is a React-component for Google AdSense / Baidu advertisement.
[](https://travis-ci.org/hustcc/react-adsense)
[](https://www.npmjs.com/package/react-adsense)
[](https://www.npmjs.com/package/react-adsense)
[](https://www.npmjs.com/package/react-adsense)
[](http://git.hust.cc/react-adsense/)
> **npm install --save react-adsense**
Before use Google AdSense, you should add the `script` at the end of HTML.
```html
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
```
```jsx
import React from 'react';
import AdSense from 'react-adsense';
// ads with no set-up
<AdSense.Google
client='ca-pub-7292810486004926'
slot='7806394673'
/>
// ads with custom format
<AdSense.Google
client='ca-pub-7292810486004926'
slot='7806394673'
style={{ width: 500, height: 300, float: 'left' }}
format=''
/>
// responsive and native ads
<AdSense.Google
client='ca-pub-7292810486004926'
slot='7806394673'
style={{ display: 'block' }}
layout='in-article'
format='fluid'
/>
// auto full width responsive ads
<AdSense.Google
client='ca-pub-7292810486004926'
slot='7806394673'
style={{ display: 'block' }}
format='auto'
responsive='true'
layoutKey='-gw-1+2a-9x+5c'
/>
```
- Required props:
- `client`
- `slot`
- Optional props:
- `className`:
- `style`:
- `layout`:
- `layoutKey`:
- `format`:
- `responsive`:
- `Baidu` advertisement supported.
MIT@[hustcc](https://github.com/hustcc).
> react-adsense