Skip to content

Commit

Permalink
Fixes inputcontrol ref forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaganugur committed Oct 15, 2021
1 parent 56a2608 commit e1b166c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/input-control/index.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Input, InputProps } from '@chakra-ui/react';
import { useField } from 'formik';
import React, { FC } from 'react';
import React, { FC, ForwardedRef } from 'react';
import { BaseProps, FormControl } from '../form-control';

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

export const InputControl: FC<InputControlProps> = (
props: InputControlProps
) => {
const { name, label, inputProps, ...rest } = props;
const [field] = useField(name);
export const InputControl: FC<InputControlProps> = 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} />
</FormControl>
);
};
return (
<FormControl name={name} label={label} {...rest}>
<Input {...field} id={name} {...inputProps} ref={ref} />
</FormControl>
);
}
);

export default InputControl;

0 comments on commit e1b166c

Please sign in to comment.