-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Wrapper type breaks types with props other than children #970
Comments
Could you provide a full repro how |
Sure thing! we are wanting to sometimes use it as such: type AppWrapperProps = {
userProviderProps?: UserProviderProps
}
export const AppWrapper: React.FC<AppWrapperProps> = ({
children,
userProviderProps = { user: mockUser },
}) => (
<UserProvider {...userProviderProps}>
{children}
</UserProvider>
)
...
render(<Page {...defaultPageProps.props} />, {
wrapper: AppWrapper,
})
// OR
render(
<AppWrapper userProviderProps={{ ...user }}>
<Page {...defaultPageProps.props} />
</AppWrapper>
) this gives us the ability to use the same component in multiple ways and overriding some props in the provider |
Came here with a very similar issue. The latest release caused new TS type mismatch errors for wrapper. |
`@testing-library/react` introduced new type definition for `wrapper` in PR testing-library/react-testing-library#966, then released it in `v12.1.1`. issue testing-library/react-testing-library#970
`@testing-library/react` introduced new type definition for `wrapper` in PR testing-library/react-testing-library#966, then released it in `v12.1.1`. issue testing-library/react-testing-library#970 5420890
@testing-library/react
version: 12.1.1Relevant code or config:
What you did:
Upgraded @testing-library/react to 12.1.1
What happened:
Type for wrapper broken in #966
Reproduction:
Use wrapper component that has some props that can be passed
Problem description:
The type being inflexible (only allowing
children
) means that the wrapper can't take props if used anywhere elseSuggested solution:
Something like
wrapper?: React.ComponentType<React.PropsWithChildren>
The text was updated successfully, but these errors were encountered: