Links
Comment on page

useVariable

Usage

Use the hook with no input parameters (returns a list of variables)
const {
qLayout,
qInfo,
qMeta,
qSelectionInfo,
qVariableList
variableList,
} = useVariable();
You can also pass qId or qName as parameters. This will return data and actions for a specific variable.
const {
qLayout,
qInfo,
qNum,
qText,
value,
error,
qProperties,
setProperties
} = useVariable({ name: “name" });
Pass qName and qDefinitionto create a session variable
const {
qLayout,
qInfo
} = useVariable({
name: "name",
definition: "=Count(Country)",
});

Variable Options

The following options can be passed into the hook
  • name: String
    • The name of the variable to use. Combine with qDefinition, or pass on it's own to retrieve information from the engine
  • definition: String
    • Variable expression

Variable Properties

The following properties are returned from the hook
  • qLayout: Object
    • Layout of the variable
    • Returns an object with the following keys if no variable is passed into the hook
      • qInfo: {qId: "...", qType: "...."}
      • qMeta: {privileges: Array(3)}
      • qSelectionInfo: Object
      • qVariableList: {qItems: <Array>}
      • variableList: <Array[Obj]>
    • Returns an object with the following keys if a variable is passed into the hook
      • qInfo: {qId: "...", qType: "...."}
      • qMeta: {privileges: Array(3)}
      • qText: String
      • qNum: Number
      • value: String
      • qProperties: Returns data in this structure
      • setProperties: Returns data in this structure
  • The above properties in qLayout are also available de-structured from the hook, see the usage examples above

Example

A working example using Motor to update a slider can be found here.