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

facing issue inputcontrol when I use useRefs hook #74

Closed
anshuopinion opened this issue Sep 19, 2021 · 4 comments
Closed

facing issue inputcontrol when I use useRefs hook #74

anshuopinion opened this issue Sep 19, 2021 · 4 comments

Comments

@anshuopinion
Copy link

image

@suparjitoteo
Copy link

Hi @anshuopinion ,

I think it's because the component does not forward the ref.
I have the same issue. I copied the code from the repo and forwarded the ref.
Then I import the InputControl from this newly created file instead of the package.

import { Input, InputProps } from "@chakra-ui/react";
import { useField } from "formik";
import { BaseProps, FormControl } from "formik-chakra-ui/dist/form-control";
import React from "react";
import { ForwardedRef } from "react";

export type InputControlProps = BaseProps & {
  inputProps?: InputProps;
};

export const InputControl = React.forwardRef(
  (props: InputControlProps, ref: ForwardedRef<HTMLInputElement>) => {
    const { name, label, inputProps, ...rest } = props;
    const [field] = useField(name);

    return (
      <FormControl name={name} label={label} {...rest}>
        <Input {...field} id={name} {...inputProps} ref={ref} />
      </FormControl>
    );
  }
);

export default InputControl;

@ahmad-reza619
Copy link

Hello is this issue taken? i would like to help 😃

@suparjitoteo
Copy link

suparjitoteo commented Oct 11, 2021

@ahmad-reza619 Hi, I believe this issue is not taken yet. Not sure if the author gonna include the fix in the next version. Not many activities here recently.

@thekaganugur
Copy link
Owner

Hi, I've been really busy, and to be honest, I probably won't have time to fix ref forwarding on all components but I will release a fix for InputControl now.

Will release a new version for other components in few days.

@ahmad-reza619 I will accept PR's if you want to contribute.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants