Skip to content

Commit f511af5

Browse files
authored
fix(prop-types): remove usage of proptypes (#1140)
1 parent d707fc2 commit f511af5

File tree

6 files changed

+13
-49
lines changed

6 files changed

+13
-49
lines changed

packages/use-dataloader/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
"directory": "packages/use-dataloader"
2626
},
2727
"license": "MIT",
28-
"dependencies": {
29-
"prop-types": "15.8.1"
30-
},
3128
"peerDependencies": {
3229
"react": "18.x"
3330
}

packages/use-dataloader/src/DataLoaderProvider.tsx

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import PropTypes from 'prop-types'
21
import type { ReactElement, ReactNode } from 'react'
32
import { createContext, useCallback, useContext, useMemo, useRef } from 'react'
43
import {
@@ -56,17 +55,19 @@ export type IDataLoaderContext = {
5655
// @ts-expect-error we force the context to undefined, should be corrected with default values
5756
export const DataLoaderContext = createContext<IDataLoaderContext>(undefined)
5857

58+
type DataLoaderProviderProps = {
59+
children: ReactNode
60+
cacheKeyPrefix?: string
61+
onError?: OnErrorFn
62+
maxConcurrentRequests?: number
63+
}
64+
5965
const DataLoaderProvider = ({
6066
children,
61-
cacheKeyPrefix,
67+
cacheKeyPrefix = '',
6268
onError,
63-
maxConcurrentRequests,
64-
}: {
65-
children: ReactNode
66-
cacheKeyPrefix: string
67-
onError: OnErrorFn
68-
maxConcurrentRequests?: number
69-
}): ReactElement => {
69+
maxConcurrentRequests = DEFAULT_MAX_CONCURRENT_REQUESTS,
70+
}: DataLoaderProviderProps): ReactElement => {
7071
const requestsRef = useRef<Requests>({})
7172

7273
const computeKey = useCallback(
@@ -82,7 +83,7 @@ const DataLoaderProvider = ({
8283
const addRequest = useCallback(
8384
(key: string, args: UseDataLoaderInitializerArgs) => {
8485
if (DataLoader.maxConcurrent !== maxConcurrentRequests) {
85-
DataLoader.maxConcurrent = maxConcurrentRequests as number
86+
DataLoader.maxConcurrent = maxConcurrentRequests
8687
}
8788
if (key && typeof key === 'string') {
8889
const newRequest = new DataLoader({
@@ -212,19 +213,6 @@ const DataLoaderProvider = ({
212213
)
213214
}
214215

215-
DataLoaderProvider.propTypes = {
216-
cacheKeyPrefix: PropTypes.string,
217-
children: PropTypes.node.isRequired,
218-
maxConcurrentRequests: PropTypes.number,
219-
onError: PropTypes.func,
220-
}
221-
222-
DataLoaderProvider.defaultProps = {
223-
cacheKeyPrefix: undefined,
224-
maxConcurrentRequests: DEFAULT_MAX_CONCURRENT_REQUESTS,
225-
onError: undefined,
226-
}
227-
228216
export const useDataLoaderContext = (): IDataLoaderContext =>
229217
useContext(DataLoaderContext)
230218

packages/use-dataloader/src/__tests__/usePaginatedDataLoader.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const initialProps = {
1919
}),
2020
),
2121
}
22-
// eslint-disable-next-line react/prop-types
2322
const wrapper = ({ children }: { children?: ReactNode }) => (
2423
<DataLoaderProvider>{children}</DataLoaderProvider>
2524
)

packages/use-i18n/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"date-fns": "2.29.3",
3434
"filesize": "10.0.6",
3535
"international-types": "0.3.6",
36-
"intl-messageformat": "10.2.5",
37-
"prop-types": "15.8.1"
36+
"intl-messageformat": "10.2.5"
3837
},
3938
"peerDependencies": {
4039
"date-fns": "2.x",

packages/use-i18n/src/usei18n.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type { NumberFormatOptions } from '@formatjs/ecma402-abstract'
22
import type { Locale as DateFnsLocale } from 'date-fns'
33
import { formatDistanceToNow, formatDistanceToNowStrict } from 'date-fns'
44
import type { BaseLocale } from 'international-types'
5-
import PropTypes from 'prop-types'
65
import type { ReactElement, ReactNode } from 'react'
76
import {
87
createContext,
@@ -397,17 +396,4 @@ const I18nContextProvider = ({
397396
return <I18nContext.Provider value={value}>{children}</I18nContext.Provider>
398397
}
399398

400-
I18nContextProvider.propTypes = {
401-
children: PropTypes.node.isRequired,
402-
defaultDateLocale: PropTypes.shape({}),
403-
defaultLoad: PropTypes.func.isRequired,
404-
defaultLocale: PropTypes.string.isRequired,
405-
defaultTranslations: PropTypes.shape({}),
406-
enableDebugKey: PropTypes.bool,
407-
enableDefaultLocale: PropTypes.bool,
408-
loadDateLocale: PropTypes.func,
409-
localeItemStorage: PropTypes.string,
410-
supportedLocales: PropTypes.arrayOf(PropTypes.string).isRequired,
411-
}
412-
413399
export default I18nContextProvider

pnpm-lock.yaml

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)