react-hook-form / input

📋 Wrapper component for controlled inputs
https://react-hook-form.com/api#Controller
158 stars 14 forks source link

Replace ReactElement to ReactType #20

Closed JeromeDeLeon closed 4 years ago

JeromeDeLeon commented 4 years ago

The hurdles we have are that first, we need innerProps if user wants to pass props to the inner component and also to improve performance, they might wanna memoize the object to avoid re-rendering because some component like RadioGroup has name prop which collides with our name prop hence innerProps. Second, for TS users, they need to explicitly pass the props of the component that will replace the RHFInput inside since we're making a generic component here. I'm not very familiar around typescript. I might as well ask @barrymay or @stramel for improvement or if I did wrong here.

JeromeDeLeon commented 4 years ago

I do want to avoid explicit types for input or select tag. Do you know how to do that, @bluebill1049 ? If so, feel free to takeover.

JeromeDeLeon commented 4 years ago

Well same thing is happening but with just innerProps to avoid collision

<RHFInput as={<RadioGroup aria-label="something" />} />
JeromeDeLeon commented 4 years ago

At first, I thought just spreading the props works but then collision happens

bluebill1049 commented 4 years ago

by the way, next time @JeromeDeLeon dont fork it just branch off the master. you are member of the entire react hook form repo group

JeromeDeLeon commented 4 years ago

by the way, next time @JeromeDeLeon dont fork it just branch off the master. you are member of the entire react hook form repo group

Sorry, I'm still not familiar with git in general. Actually, I tried to create a branch locally however, I'm stuck with publishing it remotely.

bluebill1049 commented 4 years ago

by the way, next time @JeromeDeLeon dont fork it just branch off the master. you are member of the entire react hook form repo group

Sorry, I'm still not familiar with git in general. Actually, I tried to create a branch locally however, I'm stuck with publishing it remotely.

that's all good bro :)

bluebill1049 commented 4 years ago

by the way, I don't think @barrymay and @stramel are helping the repo at the moment. (at least for now)

JeromeDeLeon commented 4 years ago

by the way, I don't think @barrymay and @stramel are helping the repo at the moment. (at least for now)

I see. I'd really like to get their opinion on this one.

<RHFInput<SelectProps> as={Select} />

It doesn't feel right to me.

bluebill1049 commented 4 years ago

by the way, I don't think @barrymay and @stramel are helping the repo at the moment. (at least for now)

I see. I'd really like to get their opinion on this one.

<RHFInput<SelectProps> as={Select} />

It doesn't feel right to me.

to be honest, I think this looks over complicated

<RHFInput as={Select} /> I would only aim for this

bluebill1049 commented 4 years ago
Screen Shot 2019-12-07 at 7 53 11 pm
bluebill1049 commented 4 years ago

asFragment() instead of asFragment