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
const widgetModel: IContent = useModel(key? string);
// empty key parameter returns the model of the widget you are currently coding.
IContent type interface
interface IContent {
//widget's element ID
key: string;
//widget's classname
type?: string;
style?: {}; //doesn't even work
//contents of the widget's formfield
content?: {};
//widget's classname
cl?: string;
pin?: boolean; //doesn't even work
html?: boolean; //DONT DOCUMENT
//icons set on the widget
icons?: { [key: string]: IShape };
actions?: string[];
children?: string[];
}
Example
Observe another widget’s form-field value.
import { useModel } from 'vev';
export default function({ trackedWidget }: Props) {
const usemodel = useModel(trackedWidget.key);
return <h1>{usemodel.content.text}</h1>
}