@b3w/react-statistic
v0.5.5
Published
A simple react component that send request during route change
Downloads
8
Readme
b3w React statistic sender
Install
$ yarn add @b3w/react-statistic
Examples
Use as component
import { Statistic } from '@b3w/react-statistic';
// inside your component return
const App = () => (
<BrowserRouter>
<Statistic
path="/referer/statistic"
headers={{ someHeader: true }}
/>
<Routes />
</BrowserRouter>
);
Use as hook
import { useStatistic } from '@b3w/react-statistic';
const Component = () => {
useStatistic({
path: '/referer/statistic',
headers: {
someHeader: true
}
});
return <div>Text</div>;
};
export default Component;
Use as HOC
import { withStatistic } from '@b3w/react-statistic';
const Component = () => {
return <div>Text</div>;
};
const params = {
path: '/referer/statistic',
headers: {
someHeader: true
}
};
export default withStatistic(Component, params);
Headers param is optional.