diff --git a/README.md b/README.md index b8bcf4a..f4d6b3f 100644 --- a/README.md +++ b/README.md @@ -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, + } } ``` @@ -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 diff --git a/package.json b/package.json index ebab6e5..a4c2a19 100644 --- a/package.json +++ b/package.json @@ -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": "*" diff --git a/src/TrackingPropType.js b/src/TrackingPropType.js deleted file mode 100644 index 5c0ab89..0000000 --- a/src/TrackingPropType.js +++ /dev/null @@ -1,6 +0,0 @@ -import PropTypes from 'prop-types'; - -export default PropTypes.shape({ - trackEvent: PropTypes.func, - getTrackingData: PropTypes.func, -}); diff --git a/src/__tests__/e2e.test.js b/src/__tests__/e2e.test.js index f68f122..dfb835f 100644 --- a/src/__tests__/e2e.test.js +++ b/src/__tests__/e2e.test.js @@ -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(); @@ -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 ( @@ -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); diff --git a/src/__tests__/index.test.js b/src/__tests__/index.test.js index 7c39287..d73edaa 100644 --- a/src/__tests__/index.test.js +++ b/src/__tests__/index.test.js @@ -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(); }); diff --git a/src/index.js b/src/index.js index 87a1b9a..159d47b 100644 --- a/src/index.js +++ b/src/index.js @@ -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 }; diff --git a/src/withTrackingComponentDecorator.js b/src/withTrackingComponentDecorator.js index c932b35..20e63f7 100644 --- a/src/withTrackingComponentDecorator.js +++ b/src/withTrackingComponentDecorator.js @@ -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'; @@ -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;