Skip to content

Commit

Permalink
fix: update hook usrTrimmedInput
Browse files Browse the repository at this point in the history
  • Loading branch information
kleysc committed Jan 11, 2025
1 parent bf91143 commit b97ffee
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apps/router/src/hooks/custom/useTrimmedInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ import { useState } from 'react';

const cleanInput = (value: string) => value.trim();

export const useTrimmedInput = (initialValue = '') => {
const [value, setValue] = useState(initialValue);

const handleChange = (newValue: string) => {
setValue(cleanInput(newValue));
};

return [value, handleChange] as const;
};

export const useTrimmedInputArray = (initialValues: string[]) => {
const [values, setValues] = useState<string[]>(initialValues);

Expand Down

0 comments on commit b97ffee

Please sign in to comment.