Skip to content

Commit d60572d

Browse files
Merge pull request #276 from commitd/stuarthendren/issue275
fix(componentsprovider): explicitly add children prop
2 parents 05e9027 + 639434d commit d60572d

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/components/ComponentsProvider/ComponentsProvider.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { FC } from 'react'
1+
import React, { FC, PropsWithChildren } from 'react'
22
import { ConditionalWrapper } from '../../utils'
33
import { ThemeProvider, ThemeProviderProps } from '../ThemeProvider'
44
import { ToastProvider, ToastViewport } from '../Toast'
@@ -51,13 +51,9 @@ export type ComponentsProviderProps = {
5151
* For each provider/component a configuration object can be passed with the relevant props.
5252
* To disable a particular provider set the configuration parameter to `false`.
5353
*/
54-
export const ComponentsProvider: FC<ComponentsProviderProps> = ({
55-
theme = {},
56-
tooltip = {},
57-
toast = {},
58-
viewport = {},
59-
children,
60-
}) => (
54+
export const ComponentsProvider: FC<
55+
PropsWithChildren<ComponentsProviderProps>
56+
> = ({ theme = {}, tooltip = {}, toast = {}, viewport = {}, children }) => (
6157
<ConditionalWrapper
6258
condition={toast}
6359
wrapper={(wrappedChildren) => (

src/utils/test-utils.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import '@testing-library/jest-dom'
1010
import '@testing-library/jest-dom/extend-expect'
1111
import { render, RenderOptions, RenderResult } from '@testing-library/react'
1212
import userEvent from '@testing-library/user-event'
13-
import React from 'react'
13+
import React, { PropsWithChildren } from 'react'
1414
import ResizeObserver from 'resize-observer-polyfill'
1515
import { ComponentsProvider } from '..'
1616
import './domrect-polyfill'
@@ -24,13 +24,13 @@ global.ResizeObserver = ResizeObserver
2424
// releasePointerCapture called by some radix components but not in js-dom
2525
global.HTMLElement.prototype.releasePointerCapture = () => undefined
2626

27-
const LightTheme: React.FC = ({ children }) => (
27+
const LightTheme: React.FC<PropsWithChildren<unknown>> = ({ children }) => (
2828
<ComponentsProvider theme={{ choice: 'light' }}>
2929
{children}
3030
</ComponentsProvider>
3131
)
3232

33-
const DarkTheme: React.FC = ({ children }) => (
33+
const DarkTheme: React.FC<PropsWithChildren<unknown>> = ({ children }) => (
3434
<ComponentsProvider theme={{ choice: 'dark' }}>{children}</ComponentsProvider>
3535
)
3636

0 commit comments

Comments
 (0)