Introduction
An Introduction to Motor's hooks
This section covers the React hooks in the package which you can use to interact with the Qlik engine. You can use these hooks to perform a range of functions including extracting data or performing actions against the engine, such as making selections.
The data returned from these hooks has been simplified for easy implementation with generic UX and charting libraries, so you don't need detailed knowledge of the Qlik API and topics such as HyperCubes.

Simple Example

Let's start with an example. Say you wanted to create a filter, well import the hook, pass in a dimension and let's explore the data that's returned.
1
import { useList } from "@motor-js/engine"
2
3
const Filter = () => {
4
5
const dimension = ['Country'];
6
7
const {
8
listData,
9
} = useList({
10
dimension,
11
});
12
13
console.log(listData);
14
15
return (
16
<div></div>
17
);
18
19
};
Copied!
Above, we have passed into the hook a dimension called Country (which is a field in our Qlik application) and are returning an listData array.
This array contains objects with the Country data returned from the engine, in the format below.
1
[
2
{
3
key: 1,
4
text: 'France',
5
number: NaN
6
},
7
{
8
key: 2,
9
text: 'Germany',
10
number: NaN
11
},
12
{
13
key: 3,
14
text: 'Spain',
15
number: NaN
16
}
17
]
Copied!
We have an array of objects containing a key, text value and number value, all returned from the Qlik engine.
We can now map over this data for presentation on your UI and make selections on the key field. You can find a complete filter example below:
Last modified 6mo ago
Copy link