nandorojo / dripsy

🍷 Responsive, unstyled UI primitives for React Native + Web.
https://dripsy.xyz
MIT License
2.01k stars 80 forks source link

Can't get `ElementRef` type from `styled` comp #225

Closed jjenzz closed 2 years ago

jjenzz commented 2 years ago

The following CardElement type will be never but ideally would be ReactNative.View.

const Card = styled(ReactNative.View)({});

// Later 
type CardElement = React.ElementRef<typeof Card>;

Here's an example that works as expected without the styled wrapper:

image

jjenzz commented 2 years ago

i wanted to have a look at solving this but i'm having trouble getting the project to run locally.

i need to run yarn before i can do yarn bootstrap (from the contributing guidelines) but it fails at the postinstall step.

if you know a quick solution to this, i'm happy to take a look at the types :)

image

nandorojo commented 2 years ago

Hey @jjenzz, sorry I missed this. Happy to help you get this spun up.

if you know a quick solution to this, i'm happy to take a look at the types :)

Could you suggest it here?

I'm also going to clone this fresh to try to reproduce the setup issue you got. I was first getting used to complex types when TS released 4.4 with string literals, so the types for Dripsy are a bit of a mess haha. I've been wanting to get ElementRef working for a while, so if you have a solution that would be amazing. I've always found it hard to get it working when using an HOC wrapping a component which might have a ref.

jjenzz commented 2 years ago

i've since gotten a new laptop and pulling the project worked fine this time. i've pushed a pr with a fix https://github.com/nandorojo/dripsy/pull/237