Skip to content

Commit

Permalink
Merge pull request #906 from thundersdata-frontend/rn-issue
Browse files Browse the repository at this point in the history
fix: 修复TextArea设置value无效的bug
  • Loading branch information
chj-damon authored Oct 8, 2024
2 parents 739c759 + c514138 commit 96d68e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/curly-balloons-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@td-design/react-native': patch
---

fix: 修复TextArea设置value无效的bug
8 changes: 7 additions & 1 deletion packages/react-native/src/input/useTextArea.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { useEffect } from 'react';

import { useSafeState } from '@td-design/rn-hooks';

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

export default function useTextArea({ value, onChange }: Pick<TextAreaProps, 'value' | 'onChange'>) {
const [inputValue, setInputValue] = useSafeState(value);
const [inputValue, setInputValue] = useSafeState<string>();

useEffect(() => {
setInputValue(value ?? '');
}, [value]);

const handleChange = (val: string) => {
setInputValue(val);
Expand Down

0 comments on commit 96d68e5

Please sign in to comment.