Closed rickgaurav closed 6 years ago
Thanks @rickgaurav ! This is noted early in the doc,
The decorator can be used on React Classes and on methods within those classes. If you use it on methods within these classes, make sure to decorate the class as well.
Maybe we can make that more obvious instead of adding this new "gotcha" section? Could add a comment to the code snippet perhaps. Something like:
import React from 'react';
import track from 'react-tracking';
@track({ page: 'FooPage' })
export default class FooPage extends React.Component {
@track({ action: 'click' }) // be sure to have decorated the class for this to work
handleClick = () => {
// ... other stuff
};
render() {
return <button onClick={this.handleClick}>Click Me!</button>;
}
}
I think this might also be helpful for a future FAQ I'd like to put together, #86
Ahhh, I missed it. I guess its emphasised enough then. Adding a comment in code is enough. I will close the PR.
Add some points which are easy to be missed but are really required to be taken care of, in order for tracking to work correctly.