1.0.2 • Published 3 years ago

@caast/react-use-caast v1.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

Install

yarn add @caast/react-use-caast
# or
npm i @caast/react-use-caast --save

Description

This hook allow you to simply implement Caast library on a React project. It will inject the library in your DOM with your provided API keys. The caast instance will then be available in order to perform the available actions of the library.

Usage

import React, { useState, useEffect } from 'react';
import useCaast from '@caast/react-use-caast';

export default function App() {
  const caastInstance = useCaast({ app_id: 'MY_APP_ID', app_key: 'MY_APP_KEY' });

  useEffect(() => {
    if (caastInstance) {
      console.log('Caast is now loaded, you can now call Caast library methods', caastInstance.infos());
    }
  }, [caastInstance]);
}