useStringField
Reads the value of a string field.
function useStringField(props: {field: string; defaultValue?: string}): string | null
Arguments
| Property | Type | Description |
|---|---|---|
| field | string | The name of the field. |
| defaultValue | string | The value returned while the field is empty. |
Returns
The text the user entered. If the field is empty, the defaultValue, or null without a defaultValue.
Example
src/widgets/example/Example.tsx
import React from 'react'
import {useStringField} from '@modbros/dashboard-sdk'
export default function Example() {
const text = useStringField({field: 'example', defaultValue: 'Hello'})
return <span>{text}</span>
}