github nytimes/react-tracking v8.1.0
v8.1.0 - Full React Hooks support

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

Thanks to @bgergen in #168 and #171 (testing support from @tizmagik in #165 and #170 ) react-tracking now fully supports React Hooks for all features (e.g. Hooks can be used completely instead of, or in addition to, the HoC/decorator API).

import { useTracking } from 'react-tracking';

const FooPage = () => {
  const { Track, trackEvent } = useTracking({ page: 'FooPage' });

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

See the full docs in the main README starting here.

Don't miss a new react-tracking release

NewReleases is sending notifications on new releases.