Skip to content

Commit e8e9632

Browse files
committed
fix: 修复Input组件无法输入中文的bug
1 parent 0648f3c commit e8e9632

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

.changeset/honest-crews-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@td-design/react-native': patch
3+
---
4+
5+
fix: 修复Input组件无法输入中文的bug

packages/react-native/src/input/useInput.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ export default function useInput({
1919
}, [value, defaultValue]);
2020

2121
const handleChange = (val: string) => {
22-
if (onChange) {
23-
onChange(val);
24-
} else {
25-
setInputValue(val);
26-
}
22+
setInputValue(val);
23+
onChange?.(val);
2724
};
2825

2926
const handleInputClear = () => {

packages/react-native/src/input/useInputItem.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ export default function useInputItem({
1919
}, [value, defaultValue]);
2020

2121
const handleChange = (val: string) => {
22-
if (onChange) {
23-
onChange(val);
24-
} else {
25-
setInputValue(val);
26-
}
22+
setInputValue(val);
23+
onChange?.(val);
2724
};
2825

2926
const handleInputClear = () => {

packages/react-native/src/input/useTextArea.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ export default function useTextArea({ value, onChange }: Pick<TextAreaProps, 'va
66
const [inputValue, setInputValue] = useSafeState(value);
77

88
const handleChange = (val: string) => {
9-
if (onChange) {
10-
onChange(val);
11-
} else {
12-
setInputValue(val);
13-
}
9+
setInputValue(val);
10+
onChange?.(val);
1411
};
1512

1613
return {

0 commit comments

Comments
 (0)