Spotlight Searc
Installation
To install the Quest react-native-sdk into your project, follow these steps:
Open your terminal/command prompt.
Navigate to your project's root directory using the
cdcommand if you're not already there.Run the following command to install the
quest-sdkpackage using npm:
npm install @questlabs/react-native-sdkThis command will download and install the package and its dependencies into your project.
Usage
Root Component
Import the QuestProvider Component: Import the
QuestProvidercomponent from the@questlabs/react-sdkpackage.
import { QuestProvider } from '@questlabs/react-sdk';Pass the Required Props: Pass the required props to the
QuestProvider. The required props areapiKey,apiSecret,entityIdandauthenticationToken.
Component Usage
To integrate the SearchBar component into your React native application, follow these steps.
Import useSearchBar Hook: Import the
useSearchBarcomponent from the@questlabs/react-sdkpackage.Import the SearchBar Component: Import the
QuestListcomponent from the@questlabs/react-sdkpackage.Pass the Required Props: Pass the required props to the
useSearchBar. The required props arequestId,questUserId, anduserTokenor if user don't have quest User id then they can pass own userId to get questUserId and Token.
import { useSearchBar , SearchBar } from "@questlabs/react-native-sdk";Props of SearchBar Component
The SearchBar component accepts the following props
actions
ICriteria[]
Require
In offline user need to provide the require filed data.
loading
boolean
optional
don't use in offline mode.
onError
Function
optional
For Showing the Error.
visible
boolean
Require
To show the component as modal
setVisible
Function
Require
Create a fucntion for close comopnent
styleConfig
styleConfig
optional
An object containing Styling properties for styling various components within the get started process, including form, topbar, headings, descriptions, and buttons.
Style Props
styleConfig {
Form?: ViewStyle;
Topbar?: ViewStyle;
Heading?: TextStyle;
Description?: TextStyle;
ListCard?:ViewStyle;
Footer?: {
FooterStyle?: ViewStyle;
FooterText?: TextStyle;
FooterIcon?: TextStyle;
};
}Example Usage
App.js
import { SafeAreaView, StyleSheet, StatusBar } from "react-native";
import React, { useState } from "react";
import { QuestProvider } from "@questlabs/react-native-sdk";
import DemoComponent from "./DemoComponent";
export default function App() {
return (
<SafeAreaView style={styles.container}>
<StatusBar />
<QuestProvider
apiKey="Your-Api-Key"
apiSecret="Your-Api-Secret"
entityId="Your-Api-entityId"
authenticationToken="Your-authentication-token" >
<DemoComponent />
</QuestProvider>
</SafeAreaView>
);
}DemoComponent.tsx
import React from "react";
import {SearchBar,useSearchBar} from "@questlabs/react-native-sdk";
const DemoComponent = () => {
// const searchBar= useSearchBar({
// questId: "Your-Quest_ID" ,
// userId:"5235trfet365try67ywry5"
// })
const searchBar= useSearchBar({
questId: "Your-Quest_ID" ,
questUserId: "Your-user-id",
questToken: "Your-Token-id"
});
return (
<>
<TouchableOpacity style={{ padding: 10, backgroundColor: "red" }} onPress={() => setOpen(true)}>
<Text>Open</Text>
</TouchableOpacity>
<SearchBar
actions={searchBar.actions}
visible={open}
loading={searchBar.loading}
setVisible={() => setOpen(false)}
// styleConfig={{
// Description:{color:"red"},
// Footer:{
// FooterIcon:{color:"red"}
// },
// Form:{backgroundColor:"lightgray"},
// Heading:{color:"yellow"},
// ListCard:{backgroundColor:"blue",margin:5,borderRadius:10},
// Topbar:{backgroundColor:"orange"}
// }}
/>
</>
);
};
export default DemoComponent;Demo
Last updated