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
{{ message }}
Repository navigation
Property 'ref' does not exist on type 'IntrinsicAttributes & FastOmit<ViewProps, never>'. #4143
Reacted by GuillaumeD-dougs, Nicolas Brat, Dimasprog, Lee Higgitt, Nazarii Melnyk, Orrin Manning, João Ribeiro, Sebastian Duque Gutierrez, Javier López, Wojciech Maj and 3 more
Reacted by Nazarii Melnyk, Hannibal B. Moulvad, Orrin Manning, Cleidson Oliveira, NISHARGA KABIR, Bert-Jan Verwer, Wojciech Maj, Jose Luis Leon, Maxim, Henning Hall and 4 more
Same here. TS now throws Type 'RefObject<TextInputProps & { value: string; setNativeProps: ({ text }: { text: string; }) => void; focus: () => void; }>' is not assignable to type 'Ref<TextInput> | undefined' when using something like this:
Fixed — added React.RefAttributes to the PolymorphicComponent overload's call signature so ref is accepted on both web and native styled components. Previously, the polymorphic overload lacked ref, and TS would report the error from that overload instead of falling through to the base ForwardRefExoticComponent signature.
Activity
Dimasprog commentedon Sep 22, 2023
Any solutions?
wr-lhiggitt commentedon Sep 27, 2023
I am also having this issue. It appears this is an issue for V6 versions and makes styled-components V6 unusable for react-native.
wr-lhiggitt commentedon Sep 27, 2023
FYI - I've found that if you use
styledas a function rather than using the static properties, refs seem to type properly:This example does not work:
This example does work:
nazmeln commentedon Oct 17, 2023
+1
Orrin-Manning commentedon Oct 31, 2023
+1
OliveiraCleidson commentedon Nov 2, 2023
Using
styled(TextInput)worked for me, but this doesn't smell goodhadnet commentedon Nov 24, 2023
Same here. TS now throws
Type 'RefObject<TextInputProps & { value: string; setNativeProps: ({ text }: { text: string; }) => void; focus: () => void; }>' is not assignable to type 'Ref<TextInput> | undefined'when using something like this:t0ma5h commentedon Apr 25, 2024
Same issue.
Using
styled(View)insted ofstyled.Viewworks though.gburatti commentedon Dec 5, 2024
+1
chore: fix changeset, add test:types script, optimize Substitute, fix…
quantizor commentedon Mar 19, 2026
Fixed — added
React.RefAttributesto thePolymorphicComponentoverload's call signature sorefis accepted on both web and native styled components. Previously, the polymorphic overload lackedref, and TS would report the error from that overload instead of falling through to the baseForwardRefExoticComponentsignature.chore: fix changeset, add test:types script, optimize Substitute, fix…
chore: fix changeset, add test:types, optimize Substitute, fix ref ty…
quantizor commentedon Mar 19, 2026
This fix is available in
[email protected]. Please try it and report any issues:wojtekmaj commentedon Mar 19, 2026
I confirm that [email protected] fixed it for me.
Just maybe a notable mention that I had to clean up the workaround I used before:
Other than that, no regressions on 80,000 LoC codebase.
FreTimmerman commentedon Jun 4, 2026
i can also confirm that
[email protected]fixed it for mehowever, the actual (non-prerelease)
6.4.0and newer don't have this fix? it seems it hasn't been merged in?