> For the complete documentation index, see [llms.txt](https://docs.questera.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.questera.ai/questera-ai-sdks/react-native-sdk-components/gamification/quiz-component.md).

# Quiz component

## Components Visuals&#x20;

{% tabs %}
{% tab title="Overview" %}

<figure><img src="/files/FHxGLhfEBHEeK8fHj71p" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Visual 1" %}

<figure><img src="/files/1iGwp36YBaL4srAG9Y9F" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}

{% tab title="Visual 2" %}

<figure><img src="/files/pNtaFsTwEcjm8ZQoXiXP" alt="" width="563"><figcaption></figcaption></figure>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
To unlock early access to the component                                                           [**Get Access**](https://bijfwfnqtsj.typeform.com/to/eUXDpbuh)
{% endhint %}

## 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 `cd` command if you're not already there.
* Run the following command to install the `quest-sdk` package using npm:

```jsx
npm install @questlabs/react-native-sdk
```

> This command will download and install the package and its dependencies into your project.

{% hint style="info" %}
Make sure your project has npm and Node.js installed, and that you have the necessary permissions to install packages in your project directory.
{% endhint %}

## Usage

### Root Component

* **Import the QuestProvider Component**: Import the `QuestProvider` component from the `@questlabs/react-sdk` package.

```jsx
import { QuestProvider } from '@questlabs/react-sdk';
```

* **Pass the Required Props**:  Pass the required props to the `QuestProvider`. The required props are `apiKey`,  `entityId,` `authenticationToken` and `fontFamily.`

{% hint style="info" %}
To load external fonts, please refer this doc to setup [expo-font](https://docs.expo.dev/versions/latest/sdk/font/) on your expo app.
{% endhint %}

### Component Usage

To integrate the `useGamifiedQuiz` component into your React native application, follow these steps.

* **Import useGamifiedQuiz Hook:** Import the `useGamifiedQuiz` component from the `@questlabs/react-sdk` package.
* **Import the Gamified Component**: Import the `Gamified` component from the `@questlabs/react-sdk` package.
* **Pass the Required Props**:  Pass the required props to the `useGamifiedQuiz` .  The required props are `questId`, `questUserId`, and `questToken` or if user don't have quest User id then they  can pass own userId to get questUserId and Token.&#x20;

```typescript
import { useGamifiedQuiz , Gamified } from "@questlabs/react-native-sdk";
```

{% hint style="info" %}
Don't not use QuestProvider and useGamifiedQuiz Hook in same file
{% endhint %}

## Props of Gamified Component

The Gamified component accepts the following props

<table><thead><tr><th width="207">Props Name</th><th width="173">Type</th><th width="103">Require </th><th>Details</th></tr></thead><tbody><tr><td>actions</td><td>ICriteria[]</td><td>Require</td><td>in offline user need to provide the require filed data.</td></tr><tr><td>questId</td><td>string</td><td>Optional</td><td>Provied questId</td></tr><tr><td>questUserId</td><td>string</td><td>Optional</td><td>Provied the userId</td></tr><tr><td>userToken</td><td>string</td><td>Optional</td><td>Provied Quest Token</td></tr><tr><td>loading</td><td>boolean</td><td>Optional</td><td>don't use in offline mode.</td></tr><tr><td>onUpdateAction</td><td>(actionID: string, answer: (string | number)[])</td><td>Optional</td><td>Create your oen function for updateing the action.</td></tr><tr><td>header</td><td>string</td><td>Optional</td><td>Component header text</td></tr><tr><td>campaignVariationId</td><td>string</td><td>Optional</td><td>Id For verification.</td></tr><tr><td>onError</td><td>Function</td><td>Optional</td><td>For Showing the Error.</td></tr><tr><td>styleConfig</td><td>Object</td><td>Optional</td><td>An object containing Styling properties for styling various components within the get started process, including form, topbar, headings, descriptions,  and buttons.</td></tr></tbody></table>

### Style Props

```typescript
styleConfig {
  Form?: ViewStyle;
  Heading?: TextStyle;
  Input?: ViewStyle;
  PrimaryButton?: ViewStyle | TextStyle;
  SecondaryButton?: ViewStyle | TextStyle;
  Footer?: {
    FooterStyle?: ViewStyle;
    FooterText?: TextStyle;
    FooterIcon?: TextStyle;
  };
  MultiChoice?: {
    style?: TextStyle ,
    selectedStyle?: ViewStyle
 },
  FormContainer?: ViewStyle;
  Question?: TextStyle;
  ThanksPopup?: ViewStyle;
  ThanksPopupHeading?: TextStyle;
  ThanksPopupDescription?: TextStyle;
  thanksPopUpFooter?: {
    thanksPopUpFooterStyle?: ViewStyle;
    thanksPopUpFooterText?: TextStyle;
    thanksPopUpFooterIcon?: TextStyle;
  };
  ThanksPopupGotoHome?: ViewStyle | TextStyle;
}

```

### Example Usage

App.js

```typescript
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

```typescript
import React from "react";
import {Gamified,useGamifiedQuiz} from "@questlabs/react-native-sdk";
const DemoComponent = () => {
  // const gamified= useGamifiedQuiz({
  //   questId: "Your-Quest_ID" ,
  //   userId:"5235trfet365try67ywry5"
  //   })

  const gamified= useGamifiedQuiz({
    questId: "Your-Quest_ID" ,
    questUserId: "Your-user-id",
    questToken: "Your-Token-id" 
    });
  return (
    <>
    <Gamified
        actions={gamified.actions}
        loading={gamified.loading}
        campaignVariationId={gamified.campaignVariationId}
        questId={gamified.questId}
        questToken={gamified.userToken}
        questUserId={gamified.questUserId}
        // styleConfig={
        //   {
        //     Heading:{color:"yellow"},
        //     Footer:{
        //       FooterIcon:{
        //         color:'yellow'
        //       },
        //       FooterStyle:{backgroundColor:"red"},
        //       FooterText:{color:'yellow'}
        //     },
        //     FormContainer:{backgroundColor:'gray'},
        //     Input:{backgroundColor:"red"},
        //     PrimaryButton:{backgroundColor:"red",color:"yellow"},
        //     SecondaryButton:{backgroundColor:"blue",color:"white"},
        //     Question:{color:'yellow'},
        //     ThanksPopup:{backgroundColor:"red"},
        //     ThanksPopupDescription:{color:"red"},
        //     ThanksPopupHeading:{color:'red'},
        //     ThanksPopupGotoHome:{backgroundColor:"red",color:"white"},
        //     thanksPopUpFooter: {
        //       thanksPopUpFooterText: {
        //         color: "red"
        //       },
        //       thanksPopUpFooterIcon: {
        //         color: "red"
        //       },
        //       thanksPopUpFooterStyle: {
        //         backgroundColor: "yellow"
        //       }
        //     }
        //   }
        // }

        // actions={[
        //   {
        //     actionId: "123",
        //     actionType: "USER_INPUT_TEXT",
        //     answer: [],
        //     title: "first"

        //   },
        //   {
        //     actionId: "32",
        //     actionType: "USER_INPUT_TEXT",
        //     answer: [],
        //     title: "2"

        //   },
        //   {
        //     actionId: "342",
        //     actionType: "USER_INPUT_SINGLE_CHOICE",
        //     answer: [],
        //     options: [1, 2, 3, 4, 5],
        //     title: "3"

        //   },
        //   {
        //     actionId: "123",
        //     actionType: "USER_INPUT_MULTI_CHOICE",
        //     answer: [],
        //     options: ['df5', 'afg', 'sdgfh', 'asdg'],
        //     title: "4"

        //   },
        //   {
        //     actionId: "5673563",
        //     actionType: "USER_INPUT_TEXT",
        //     answer: [],
        //     title: "5"

        //   },

        // ]}
      />
    </>
  );
};
export default DemoComponent;
```

## Demo

{% embed url="<https://www.loom.com/share/2f745db5b23045d087025a330bd927f6?sid=6149e986-029b-4852-afa2-11e77f90025e>" %}
