github nytimes/react-tracking v7.0.0
v7.0.0 - React Hooks support

latest releases: v9.3.2, v9.3.1, v9.3.0...
4 years ago

2 Breaking Changes, although the syntax/API has not changed:

New Feature: React Hooks

Thanks to @damassi in #124 we now support React Hooks 🎉

import { useTracking } from 'react-tracking';

const SomeChild = () => {
  const tracking = useTracking();

  return (
    <div
      onClick={() => {
        tracking.trackEvent({ action: 'click' });
      }}
    />
  );
};

useTracking returns the same { getTrackingData, trackEvent } methods that the @track() wrapper injects into props (as props.tracking). For now, you still need to use the wrapper in order to add contextual tracking data.

Technically the syntax is backwards compatible, but because of our use of React Hooks we now require React > v16.8, hence the breaking change.

peerDependencies Update: core-js@3

Thanks to @mckernanin in #125 we've upgraded our babel and core-js dependencies.

For more on this upgrade and how this might affect your app's build/configuration, please see: https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md

Again, syntax is backwards compatible, but peerDeps now specified an update to core-js@3 if you didn't already have it.

Don't miss a new react-tracking release

NewReleases is sending notifications on new releases.