Daily Streak Component
The Daily Visit Streak View is a component designed for tracking and displaying a user's daily visit streak. It provides a visual representation of how many user has visited a platform or app.
Components Visuals

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,entityId,authenticationTokenandfontFamily.
Component Usage
To integrate the useStreaks component into your React native application, follow these steps.
Import useStreaks Hook: Import the
useStreakscomponent from the@questlabs/react-sdkpackage.Import the Streak Component: Import the
Streakcomponent from the@questlabs/react-sdkpackage.Pass the Required Props: Pass the required props to the
useStreaks. 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 { useStreaks, Streak } from "@questlabs/react-native-sdk";Props of Streak Component
The Streak component accepts the following props
counter
number
Required
The current count for the streak.
header
string
Required
Header for the streak component.
description
string
Required
Description for the streak component.
pendingStreakImg
string
optional
Image URL for the pending streak state.
filledStreakImg
string
optional
Image URL for the filled streak state.
icon
"gift" | "fire" | string | any
optional
for icon.
iconData
TItemData[]
Required
in offline/ online user need to provide the require filed data.
loading
boolean
optional
don't use in offline mode.
Style Props
styleConfig {
IconBackground?: ViewStyle;
IconColor?: TextStyle;
Form?: ViewStyle;
Count?: TextStyle;
Heading?: TextStyle;
Description?: TextStyle;
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"
fontFamily= "Your-Font-FamFamily"
>
<DemoComponent />
</QuestProvider>
</SafeAreaView>
);
}DemoComponent.tsx
import React from "react";
import {Streak,useStreaks} from "@questlabs/react-native-sdk";
const DemoComponent = () => {
// const streakItems = useStreaks({
// questId: "Your-Quest_ID" ,
// userId:"5235trfet365try67ywry5"
// })
const streakItems = useStreaks({
questId: "Your-Quest_ID" ,
questUserId: "Your-user-id",
questToken: "Your-Token-id"
});
return (
<Streak
icon={"gift"}
counter={streakItems.count}
loading={streakItems.loading}
description="This is the description"
header="This is the header"
iconData={[
{ title: "Confident reader", range: 1 },
{ title: "Responsible reader", range: 20 },
{ title: "Serious learner", range: 40 },
{ title: "Absolute reader", range: 60 },
{ title: "Professional reader", range: 80 },
]}
filledStreakImg=""
pendingStreakImg=""
/* styleConfig={{
Count: { color: 'red', backgroundColor: "yellow" },
Description: { backgroundColor: "blue", color: "white" },
Form: { backgroundColor: "orange" },
Heading: { color: "white" },
IconBackground: { backgroundColor: "yellow" },
}} */
/>
);
};
export default DemoComponent;Demo
Last updated

