useVariable

Usage

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

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.