Vev Help Center
Searchโ€ฆ
useModel hook
Watches and returns the content model using the widget key. Content model refers to the intrinsic properties of the widget like element ID, classname, iconโ€™s, and form-field values.

Usage

1
const widgetModel: IContent = useModel(key? string);
2
// empty key parameter returns the model of the widget you are currently coding.
Copied!

IContent type interface

1
interface IContent {
2
//widget's element ID
3
key: string;
4
//widget's classname
5
type?: string;
6
style?: {}; //doesn't even work
7
//contents of the widget's formfield
8
content?: {};
9
//widget's classname
10
cl?: string;
11
pin?: boolean; //doesn't even work
12
html?: boolean; //DONT DOCUMENT
13
//icons set on the widget
14
icons?: { [key: string]: IShape };
15
actions?: string[];
16
children?: string[];
17
}
Copied!

Example

Observe another widgetโ€™s form-field value.
1
import { useModel } from 'vev';
2
โ€‹
3
export default function({ trackedWidget }: Props) {
4
const usemodel = useModel(trackedWidget.key);
5
return <h1>{usemodel.content.text}</h1>
6
}
Copied!