I'm currently sending user analytic tracking events without a HOC like so:
import React from 'react';
class NamePage extends Component {
componentDidMount() {
this.context.mixpanel.track('View Page: NamePage');
}
render() {
...
}
}
NamePage.contextTypes = {
mixpanel: PropTypes.object.isRequired
};
export default NamePage;
Given 99% of my pages will require this track function, I'm learning that, I should wrap my pages in a recompose HOC.
Can do something like:
import React from 'react';
import withTracking from '../hoc/withTracking';
class NamePage extends Component {
render() {
...
}
}
export default withTracking(NamePage, {
eventTitle: 'View Page: NamePage',
});
Is this possible? Am I setting this up correctly? Is there a better way to add a HOC for this purpose?
Thank you