Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 4 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ The `@track()` decorator will expose a `tracking` prop on the component it wraps
```js
{
// tracking prop provided by @track()
tracking: PropTypes.shape({
tracking: {
// function to call to dispatch tracking events
trackEvent: PropTypes.func,
trackEvent: (eventData: object) => void,

// function to call to grab contextual tracking data
getTrackingData: PropTypes.func,
});
getTrackingData: () => object,
}
}
```

Expand Down Expand Up @@ -507,23 +507,6 @@ This library simply merges (using [deepmerge]) the tracking data objects togethe

You can get the type definitions for React Tracking from DefinitelyTyped using `@types/react-tracking`. For an always up-to-date example of syntax, you should consult [the react-tracking type tests](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-tracking/test/react-tracking-with-types-tests.tsx).

### PropType Support

The `props.tracking` PropType is exported for use, if desired:

```js
import { TrackingPropType } from 'react-tracking';
```

Alternatively, if you want to just silence proptype errors when using [eslint react/prop-types](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/prop-types.md), you can add this to your eslintrc:

```json
{
"rules": {
"react/prop-types": ["error", { "ignore": ["tracking"] }]
}
}
```

### Deepmerge

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@
"regenerator-runtime": "^0.13.10"
},
"peerDependencies": {
"prop-types": "^15.x",
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
"react": "^18.0.0"
},
"optionalDependencies": {
"fsevents": "*"
Expand Down
6 changes: 0 additions & 6 deletions src/TrackingPropType.js

This file was deleted.

6 changes: 3 additions & 3 deletions src/__tests__/e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/* eslint-disable global-require */
import React, { useContext } from 'react';
import { mount } from 'enzyme';
import PropTypes from 'prop-types';
import hoistNonReactStatics from 'hoist-non-react-statics';

const dispatchTrackingEvent = jest.fn();
Expand Down Expand Up @@ -683,7 +682,8 @@ const runTests = useBuiltLib => {
it('does not prevent components using the legacy context API and hoist-non-react-statics < v3.1.0 from receiving updates', () => {
const withLegacyContext = DecoratedComponent => {
class WithLegacyContext extends React.Component {
static contextTypes = { theme: PropTypes.string };

static contextTypes = { theme: () => null };

render() {
return (
Expand Down Expand Up @@ -721,7 +721,7 @@ const runTests = useBuiltLib => {

@track()
class App extends React.Component {
static childContextTypes = { theme: PropTypes.string };
static childContextTypes = { theme: () => null };

constructor(props) {
super(props);
Expand Down
3 changes: 0 additions & 3 deletions src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ describe('react-tracking', () => {
it('exports useTracking', () => {
expect(index.useTracking).toBeDefined();
});
it('exports TrackingPropType', () => {
expect(index.TrackingPropType).toBeDefined();
});
it('exports track', () => {
expect(index.track).toBeDefined();
});
Expand Down
1 change: 0 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export { default as deepmerge } from 'deepmerge';

export { default as withTracking } from './withTrackingComponentDecorator';
export { default as trackEvent } from './trackEventMethodDecorator';
export { default as TrackingPropType } from './TrackingPropType';
export { default as useTracking } from './useTracking';

export { track };
Expand Down
9 changes: 0 additions & 9 deletions src/withTrackingComponentDecorator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
import hoistNonReactStatics from 'hoist-non-react-statics';
import PropTypes from 'prop-types';

import ReactTrackingContext from './ReactTrackingContext';
import useTrackingImpl from './useTrackingImpl';
Expand Down Expand Up @@ -66,14 +65,6 @@ export default function withTrackingComponentDecorator(
}

WithTracking.displayName = `WithTracking(${decoratedComponentName})`;
WithTracking.propTypes = {
rtFwdRef: PropTypes.oneOfType([
PropTypes.func,
// eslint-disable-next-line react/forbid-prop-types
PropTypes.shape({ current: PropTypes.any }),
]),
};
WithTracking.defaultProps = { rtFwdRef: undefined };

hoistNonReactStatics(WithTracking, DecoratedComponent);
return WithTracking;
Expand Down