Skip to main content

Field Hooks

Field hooks can be used to retrieve the data for configurable fields that the user entered in the sidebar of the dashboard builder for a widget.

For every type of configurable field there is a corresponding hook to retrieve the data and a another hook to set the data.

note

The setter hooks are not documented, since they all follow the same schema. They return a setter function for a field by name which can be used to update the data for a field from the widget itself.

This is how such a setter hook can be used:

src/widgets/example/Example.tsx
import React, {useEffect} from 'react'
import {useSetStringField} from '@modbros/dashboard-sdk'

export default function Example() {
const setField = useSetStringField({field: 'example'})

useEffect(() => {
setField('Some new value')
}, [])

return null
}