react-ga-hoc
v3.0.0
Published
Send GA pageview safely with async data.
Downloads
21
Maintainers
Readme
react-ga-hoc
Send GA pageview safely with async data.
Installation
$ npm install react-ga react-ga-hoc --save
Usage
- As HOC
import ga from 'react-ga';
import { pageview } from 'react-ga-hoc';
// SDK Setup
ga.initialize('id');
// Use HOC with Container
pageview(path)(
() => <div/>,
);
- ES7 decorator
@pageview()
class Container extends React.Component {
render() {
return <div/>;
}
}
API
pageview(
?path: string,
): HigherOrderComponent
| Arguments | Default | Description |
| ------------- | ------------ | -------------------------- |
| path
| current path | path to be sent a pageview |
Test
$ npm run lint
$ npm run test:watch
CONTRIBUTING
- ⇄ Pull requests and ★ Stars are always welcome.
- For bugs and feature requests, please create an issue.
- Pull requests must be accompanied by passing automated tests (
$ npm test
).