Skip to content

fix(componentsprovider): explicitly add children prop #276

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 17, 2022
Merged
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
12 changes: 4 additions & 8 deletions src/components/ComponentsProvider/ComponentsProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { FC } from 'react'
import React, { FC, PropsWithChildren } from 'react'
import { ConditionalWrapper } from '../../utils'
import { ThemeProvider, ThemeProviderProps } from '../ThemeProvider'
import { ToastProvider, ToastViewport } from '../Toast'
Expand Down Expand Up @@ -51,13 +51,9 @@ export type ComponentsProviderProps = {
* For each provider/component a configuration object can be passed with the relevant props.
* To disable a particular provider set the configuration parameter to `false`.
*/
export const ComponentsProvider: FC<ComponentsProviderProps> = ({
theme = {},
tooltip = {},
toast = {},
viewport = {},
children,
}) => (
export const ComponentsProvider: FC<
PropsWithChildren<ComponentsProviderProps>
> = ({ theme = {}, tooltip = {}, toast = {}, viewport = {}, children }) => (
<ConditionalWrapper
condition={toast}
wrapper={(wrappedChildren) => (
Expand Down
6 changes: 3 additions & 3 deletions src/utils/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '@testing-library/jest-dom'
import '@testing-library/jest-dom/extend-expect'
import { render, RenderOptions, RenderResult } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
import React, { PropsWithChildren } from 'react'
import ResizeObserver from 'resize-observer-polyfill'
import { ComponentsProvider } from '..'
import './domrect-polyfill'
Expand All @@ -24,13 +24,13 @@ global.ResizeObserver = ResizeObserver
// releasePointerCapture called by some radix components but not in js-dom
global.HTMLElement.prototype.releasePointerCapture = () => undefined

const LightTheme: React.FC = ({ children }) => (
const LightTheme: React.FC<PropsWithChildren<unknown>> = ({ children }) => (
<ComponentsProvider theme={{ choice: 'light' }}>
{children}
</ComponentsProvider>
)

const DarkTheme: React.FC = ({ children }) => (
const DarkTheme: React.FC<PropsWithChildren<unknown>> = ({ children }) => (
<ComponentsProvider theme={{ choice: 'dark' }}>{children}</ComponentsProvider>
)

Expand Down