From 0a533b64e10b4a5eef7507b2d5b83236f9ef93f7 Mon Sep 17 00:00:00 2001 From: utin-francis-peter Date: Wed, 3 Jul 2024 11:49:49 +0100 Subject: [PATCH] chore: migrated prop type definition into a types declaration file for components. other components prop types will live here --- frontend/src/components/TextArea.tsx | 17 ++--------------- frontend/src/components/types/index.ts | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 frontend/src/components/types/index.ts diff --git a/frontend/src/components/TextArea.tsx b/frontend/src/components/TextArea.tsx index b650423f..311efe81 100644 --- a/frontend/src/components/TextArea.tsx +++ b/frontend/src/components/TextArea.tsx @@ -1,18 +1,5 @@ import React, { useEffect, useRef } from 'react'; - -type Props = { - value: string | string[] | number; - isAutoFocused: boolean; - id?: string; - maxLength?: number; - name?: string; - placeholder?: string; - className?: string; - children?: React.ReactElement; - onChange: (e: React.ChangeEvent) => void; - onPaste?: (e: React.ClipboardEvent) => void; - onKeyDown?: (e: React.KeyboardEvent) => void; -}; +import { TextAreaProps } from './types'; const TextArea = ({ value, @@ -26,7 +13,7 @@ const TextArea = ({ onChange, onPaste, onKeyDown, -}: Props) => { +}: TextAreaProps) => { const textAreaRef = useRef(null); useEffect(() => { diff --git a/frontend/src/components/types/index.ts b/frontend/src/components/types/index.ts new file mode 100644 index 00000000..3cebc1c2 --- /dev/null +++ b/frontend/src/components/types/index.ts @@ -0,0 +1,23 @@ +export type TextAreaProps = { + value: string | string[] | number; + isAutoFocused: boolean; + id?: string; + maxLength?: number; + name?: string; + placeholder?: string; + className?: string; + children?: React.ReactElement; + onChange: ( + e: React.ChangeEvent, + ) => void; + onPaste?: ( + e: React.ClipboardEvent, + ) => void; + onKeyDown?: ( + e: React.KeyboardEvent, + ) => void; +}; + +export type InputProps = TextAreaProps & { + type: 'text' | 'number'; +};