TextArea
Renders a textarea element (W3schools Textarea) and accepts as props any html attribute listed at: Html Textarea Attributes.
Props
name
: string
- A field's name in Usetheform state.
- If the TextArea is rendered within a
<Collection array />
, name is not allowed as a prop.
index
: string
- A field's index in array Collection.
- index is only allowed if your TextArea is rendered within a
<Collection array />
.
value
: string
- Specifies the initial value of an textarea element.
touched
: boolean
A field that has been touched/visited. Default value of false.
If true, validation messages (sync and async) will be shown but only when the event onBlur of the field is triggered by a user action.
reducers
: array | function
(nextValue, prevValue, formState) => nextValue
- An array whose values correspond to different reducing functions.
- Reducer functions specify how the TextArea's value change.
innerRef
: object (a mutable ref object)
- When you need to access the underlying DOM node created by TextArea (e.g. to call focus), you can use a ref to store a reference to the textarea dom node.
const ref = useRef(null)<TextArea innerRef={ref} name="textarea" value="test" />
Basic usage
import { Form, TextArea } from 'usetheform'
- {} 0 keys
Reducers
import { Form, TextArea } from 'usetheform'
- {} 0 keys
Validation - Sync
import { useValidation } from 'usetheform'
- {} 0 keys
Validation - Async
import { useAsyncValidation, useForm } from 'usetheform'const Submit = () => {const { isValid } = useForm();return (<button disabled={!isValid} type="submit">Submit</button>);};
- {} 0 keys