nytimes / react-tracking

🎯 Declarative tracking for React apps.
https://open.nytimes.com/introducing-react-tracking-declarative-tracking-for-react-apps-2c76706bb79a
Other
1.87k stars 123 forks source link

Avoid referencing unbound methods Typescript error #202

Closed piersolenski closed 1 year ago

piersolenski commented 2 years ago

When using const { trackEvent } = useTracking();, Typescript throws the following error:

Avoid referencing unbound methods which may cause unintentional scoping of this. If your function does not access this, you can annotate it with this: void or consider using an arrow function instead.

We're using the https://github.com/wesbos/eslint-config-wesbos config. It seems to happen when the function is already an arrow function. The use of other hooks in the same context do not throw this error.

tizmagik commented 1 year ago

Not sure what this lint rule is meant to catch? What would the suggested fix be?

tizmagik commented 1 year ago

Closing this as I'm not sure exactly what the issue or suggested fix is. Feel free to re-open with more context. Thanks!