forked from react-component/input
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextarea-basic.tsx
More file actions
38 lines (33 loc) · 1.02 KB
/
textarea-basic.tsx
File metadata and controls
38 lines (33 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* eslint-disable no-console */
import { TextArea, type TextAreaProps } from '@rc-component/input';
import React, { useState, type ChangeEvent, type KeyboardEvent } from 'react';
export default function App() {
const [value, setValue] = useState('');
const onChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
const {
target: { value: currentValue },
} = e;
console.log(e.target.value);
setValue(currentValue);
};
const onResize: TextAreaProps['onResize'] = ({ width, height }) => {
console.log(`size is changed, width:${width} height:${height}`);
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const onPressEnter = (e: KeyboardEvent<HTMLTextAreaElement>) => {
console.log(`enter key is pressed`);
};
return (
<div>
<TextArea
prefixCls="custom-textarea"
onPressEnter={onPressEnter}
onResize={onResize}
value={value}
onChange={onChange}
autoFocus
onFocus={() => console.log('focus')}
/>
</div>
);
}