-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Types of .attrs
are still broken for React Native on 6.1.9 when using styled()
#4302
Comments
+1 on this issue. It's been annoying as it prevents react-native apps from upgrading to the latest version. Those issues have been very long-lasting. |
It seems to be an issue with Substitute/FastOmit. I patched them to use the slower Optional util, which addressed my issues. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
System:
Binaries:
npmPackages:
Reproduction
I've created a codesandbox here: https://codesandbox.io/p/sandbox/styled-components-attrs-issue-forked-swv9k8
But the crux of it is this
Errors out on
<StyledStyledComponent>
withDetails
No overload matches this call.
Overload 1 of 2, '(props: PolymorphicComponentProps<"native", FastOmit<FastOmit<Substitute<{ requiredAttr: boolean; } & { children?: ReactNode; }, { requiredAttr: boolean; } & { children?: ReactNode; }>, never>, never>, void, void, {}, {}>): Element', gave the following error.
Property 'requiredAttr' is missing in type '{ children: string; }' but required in type 'FastOmit<Substitute<FastOmit<FastOmit<Substitute<{ requiredAttr: boolean; } & { children?: ReactNode; }, { requiredAttr: boolean; } & { children?: ReactNode; }>, never>, never>, FastOmit<...>>, keyof ExecutionProps>'.
Overload 2 of 2, '(props: FastOmit<FastOmit<Substitute<{ requiredAttr: boolean; } & { children?: ReactNode; }, { requiredAttr: boolean; } & { children?: ReactNode; }>, never>, never>): ReactElement<...> | null', gave the following error.
Property 'requiredAttr' is missing in type '{ children: string; }' but required in type 'FastOmit<FastOmit<Substitute<{ requiredAttr: boolean; } & { children?: ReactNode; }, { requiredAttr: boolean; } & { children?: ReactNode; }>, never>, never>'.typescript(2769)
Steps to reproduce
Create a styled component with required props and set them with attrs using a props factory and you still have to define them again with attributes when using the component.
Expected Behavior
attrs()
should work like documented and like it worked in v5Actual Behavior
The required props have to be set again even if they've already been set by attrs using a props factory function (styled-components.com/docs/api#.attrs).
The text was updated successfully, but these errors were encountered: