diff --git a/src/components/TextInput/TextInput.tsx b/src/components/TextInput/TextInput.tsx index 0ebfb83f..ace1bb0f 100644 --- a/src/components/TextInput/TextInput.tsx +++ b/src/components/TextInput/TextInput.tsx @@ -22,6 +22,7 @@ export const TextInput = forwardRef< state, hasClearButton, value, + defaultValue, ...restProps }, inputRef, @@ -39,6 +40,7 @@ export const TextInput = forwardRef< } = useTextInput({ beforeComponent, afterComponent, + defaultValue, ...restProps, }); diff --git a/src/components/TextInput/useTextInput.ts b/src/components/TextInput/useTextInput.ts index 0e293778..efea8bc9 100644 --- a/src/components/TextInput/useTextInput.ts +++ b/src/components/TextInput/useTextInput.ts @@ -20,9 +20,10 @@ export const useTextInput = ({ beforeComponent, afterComponent, onChange, + defaultValue, ...restProps }: Omit) => { - const [innerValue, setInnerValue] = useState(''); + const [innerValue, setInnerValue] = useState(defaultValue ?? ''); const styles = useMemo( () => stylesBuilder(custom, beforeComponent?.type, afterComponent?.type), [afterComponent?.type, beforeComponent?.type, custom], diff --git a/src/services/extractInputProps/extractInputProps.ts b/src/services/extractInputProps/extractInputProps.ts index 74e6d99e..f7392519 100644 --- a/src/services/extractInputProps/extractInputProps.ts +++ b/src/services/extractInputProps/extractInputProps.ts @@ -26,7 +26,8 @@ const inputPropsKeys = [ 'src', 'step', 'value', - + 'id', + 'defaultValue', 'onClick', 'onChange', 'onKeyDown',