Skip to content

API Reference / @gtkx/react / index / useSetting

Function: useSetting() ​

useSetting<K, P>(schema, key): [SettingValue<K, P>, (value) => void]

Defined in: hooks/use-setting.d.ts:11

Reads and writes a single key of a GSettings schema, re-rendering when the stored value changes.

Type Parameters ​

K ​

K extends SettingsSchemaKeys

P ​

P extends string | number | symbol

Parameters ​

schema ​

SettingsSchema<K>

key ​

P & string

Returns ​

[SettingValue<K, P>, (value) => void]

The current value, and a setter that writes a new one back to GSettings.

Throws ​

When the key is not declared in the schema.

Released under the MPL-2.0 License.