Skip to content
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

Component wrapped with forwardRef cannot be used with Field component #2182

Closed
jbojcic1 opened this issue Jan 8, 2020 · 3 comments
Closed

Comments

@jbojcic1
Copy link
Contributor

jbojcic1 commented Jan 8, 2020

🚀 Feature request

Current Behavior

Currently FieldConfig has as properties of type React.ComponentType<FieldProps<V>['field']> | keyof JSX.IntrinsicElements | React.ComponentType and component property of type keyof JSX.IntrinsicElements | React.ComponentType<FieldProps<V>> | React.ComponentType, while component wrapped with forwardRef has ForwardRefExoticComponent type so you get the ts error if you try to use wrapped component.

Desired Behavior

Field should accept ForwardRefExoticComponent type too.

Suggested Solution

Extend the type to allow components wrapped with forwaredRef. So types would be something like:
as - React.ComponentType<FieldProps<V>['field']> | keyof JSX.IntrinsicElements | React.ComponentType | ForwardRefExoticComponent<FieldProps<V>['field']>

component - keyof JSX.IntrinsicElements | React.ComponentType<FieldProps<V>> | React.ComponentType | ForwardRefExoticComponent<FieldProps<V>>

Who does this impact? Who is this for?

Typescript users.

@jbojcic1 jbojcic1 changed the title Component wrapped with forwaredRef cannot be passed to Field component Component wrapped with forwaredRef cannot be used with Field component or field hook Jan 8, 2020
@jbojcic1 jbojcic1 changed the title Component wrapped with forwaredRef cannot be used with Field component or field hook Component wrapped with forwardRef cannot be used with field component or hook Jan 8, 2020
@jbojcic1 jbojcic1 changed the title Component wrapped with forwardRef cannot be used with field component or hook Component wrapped with forwardRef cannot be used with Field component Jan 8, 2020
@jaredpalmer
Copy link
Owner

Yep. Want to make a quick PR?

@jbojcic1
Copy link
Contributor Author

jbojcic1 commented Jan 10, 2020 via email

jbojcic1 added a commit to jbojcic1/formik that referenced this issue Jan 11, 2020
…forwardRef wrapped components with Field and FastField (jaredpalmer#2182)
@jbojcic1
Copy link
Contributor Author

jbojcic1 commented Jan 11, 2020

You probably know this already but while working on this PR I noticed that CONTRIBUTING.md is a bit outdated and there are some lint issues in formik-native package so I had to commit with --no-verify flag

jaredpalmer pushed a commit that referenced this issue Jan 11, 2020
…forwardRef wrapped components with Field and FastField (#2182) (#2193)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants