useSearch

useSearch hook. A hook allowing you to Search your applicaiton

Usage

Hooks are a new addition in React. They let you use state and other React features without writing a class. To learn more abou hook in react please read : https://reactjs.org/docs/hooks-intro.html

The motivation for introducing hooks in React are:

  • It’s hard to reuse stateful logic between components
  • Complex components become hard to understand
  • Classes confuse both people and machines
  • Complex components become hard to understand

To solve these problems, Hooks let you use more of React’s features without classes.

We have tried to expose hooks used in the libary so that you can create your own visualisations if you wish.

import { useSearch } from @motor-js/core
//...
const { searchResults, select } = useSearch({
engine,
searchValue,
dimensions,
qCount,
qGroupItemCount,
});

Once data has been retrived from the search hook it can then pass it on to an object to render its contents.

Props

info

You do not need to set the Config prop if the component is a child of the Motor component

PropDescriptionOptions / Example
engineConfiguration object to connect to the Qlik Engine, only set this if used outside of the Motor component.object
const {(engine, engineError)} = useEngine(config);
searchValueValue to be search for.string
dimensionsList of the search fields. If empty, the search is performed in all fields of the app.array
See sample syntax below
qCountNumber of search groups to return.number
See sample syntax below
qGroupItemCountNumber of search groups to return.number

Sample Syntax

useSearch configuration

import React from "react";
import { useEngine, useSearch } from "@motor-js/core";
function SearchObject({ engine }) {
const { searchResults, select } = useSearch({
engine,
searchValue,
dimensions,
qCount,
qGroupItemCount,
});
console.log("searchResults: ", searchResults);
return <div></div>;
}
export default SearchObject;
......
/>