Skip to content

Commit

Permalink
Merge pull request #414 from balbinott/master
Browse files Browse the repository at this point in the history
TextInput string to number
  • Loading branch information
iM-GeeKy authored Aug 8, 2024
2 parents a3bf46d + b43163d commit ac8e4ca
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Time/TimeInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ function TimeInput(
setControlledValue(`${value}`)
}, [value])

const onInnerChange = (text: string) => {
setControlledValue(text)
if (text !== '' && text !== '0') {
onChanged(Number(text))
const onInnerChange = (number: number) => {
setControlledValue(`${number}`)
if (number >= 0) {
onChanged(Number(number))
}
}

Expand Down Expand Up @@ -100,7 +100,9 @@ function TimeInput(
onBlur={() => setInputFocused(false)}
keyboardAppearance={theme.dark ? 'dark' : 'default'}
keyboardType="number-pad"
onChangeText={onInnerChange}
onChangeText={(e: string) => {
onInnerChange(Number(e))
}}
{...rest}
/>
{onPress && inputType === inputTypes.picker ? (
Expand Down

0 comments on commit ac8e4ca

Please sign in to comment.