'React(Typescript) FunctionComponent with forwardRef
I am interested in how to add InputComponents Type on FunctionComponent while using forwardRef same time
interface InputComponents {
InputNumber: typeof InputNumber;
}
const Input = forwardRef<HTMLInputElement, InputProps>(
(
{ label, className, prefix, suffix, disabled, error,
...htmlInputProps },
forwardedRef,
) => {
const [inputHtmlId] = useState(uniqueId("__input_id_"));
const localRef = useRef<HTMLInputElement>(null);
const focusInput = () => {
localRef.current?.focus();
};
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
