You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Required props set with attrs still has to be set again when using the component if you use a props factory function when setting the required props. So the fixes for this in #4288 that were released in 6.1.9 only seem to work if you don't use the props factory function when setting the values.
No overload matches this call.
Overload 1 of 2, '(props: PolymorphicComponentProps<"web", FastOmit<Substitute<Omit<FastOmit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "text"> & { ...; }, "ref"> & { ...; }, Partial<...>>, never>, void, void, {}, {}>): Element', gave the following error.
Property 'text' is missing in type '{}' but required in type 'FastOmit<Substitute<FastOmit<Substitute<Omit<FastOmit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "text"> & { ...; }, "ref"> & { ...; }, Partial<...>>, never>, FastOmit<...>>, keyof ExecutionProps>'.
Overload 2 of 2, '(props: FastOmit<Substitute<Omit<FastOmit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "text"> & { ...; }, "ref"> & { ...; }, Partial<...>>, never>): ReactNode', gave the following error.
Property 'text' is missing in type '{}' but required in type 'FastOmit<Substitute<Omit<FastOmit<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "text"> & { ...; }, "ref"> & { ...; }, Partial<...>>, never>'.
The issue can be resolved by not using a props factory and instead just return an object directly but then you can't access props like the theme etc. when setting the attribute values.
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
I expected required props to not have to be set again in the component if they've been set in the object returned by the props factory function passed to attrs.
Environment
System:
Binaries:
Reproduction
Required props set with
attrs
still has to be set again when using the component if you use a props factory function when setting the required props. So the fixes for this in #4288 that were released in 6.1.9 only seem to work if you don't use the props factory function when setting the values.I've created a codesandbox that shows this issue here: https://codesandbox.io/p/sandbox/cool-sun-ss245l?file=%2Findex.tsx.
The repro can basically be boiled down to this:
which results in this error:
The issue can be resolved by not using a props factory and instead just return an object directly but then you can't access props like the theme etc. when setting the attribute values.
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
I expected required props to not have to be set again in the component if they've been set in the object returned by the props factory function passed to
attrs
.Actual Behavior
The required props have to be set again even if they've already been set by attrs using a props factory function (https://styled-components.com/docs/api#.attrs).
The text was updated successfully, but these errors were encountered: