Skip to main content

useStringField

Reads the value of a string field.

function useStringField(props: {field: string; defaultValue?: string}): string | null

Arguments

PropertyTypeDescription
fieldstringThe name of the field.
defaultValuestringThe 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>
}