Skip to content

Commit 96d68e5

Browse files
authored
Merge pull request #906 from thundersdata-frontend/rn-issue
fix: 修复TextArea设置value无效的bug
2 parents 739c759 + c514138 commit 96d68e5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed
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: 修复TextArea设置value无效的bug

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
import { useEffect } from 'react';
2+
13
import { useSafeState } from '@td-design/rn-hooks';
24

35
import type { TextAreaProps } from './TextArea';
46

57
export default function useTextArea({ value, onChange }: Pick<TextAreaProps, 'value' | 'onChange'>) {
6-
const [inputValue, setInputValue] = useSafeState(value);
8+
const [inputValue, setInputValue] = useSafeState<string>();
9+
10+
useEffect(() => {
11+
setInputValue(value ?? '');
12+
}, [value]);
713

814
const handleChange = (val: string) => {
915
setInputValue(val);

0 commit comments

Comments
 (0)