Skip to content

damiandominella/react-videoask-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React Video Ask hook

Easily manage video ask on react

With this custom hook, you can easily use and customize the behavior of any videoask video!

Features

Installation

$ yarn add react-videoask-hook
# or
$ npm install react-videoask-hook

How to use

Basic usage

import { VideoAskProvider } from 'react-videoask-hook';

const App = () => {
  const videoAskConfig = {
    kind: 'widget',
    url: 'https://www.videoask.com/<video-id>',
    options: {
      widgetType: 'VideoThumbnailWindowTall',
      position: 'bottom-left',
    },
  };

  return (
    <VideoAskProvider config={config}>
      <p>My awesome app</p>
    </VideoAskProvider>
  );
};

With custom callbacks

import { VideoAskProvider } from 'react-videoask-hook';

const App = () => {
  const videoAskConfig = {
    kind: 'widget',
    url: 'https://www.videoask.com/<video-id>',
    options: {
      widgetType: 'VideoThumbnailWindowTall',
      position: 'bottom-left',
    },
  };

  return (
    <VideoAskProvider
      config={config}
      callbacks={{
        onMessage(params) {
          console.log(params);
        },
        onLoadModal() {
          console.log('on-load-modal');
        },
        onCloseModal(removeWidget) {
          console.log('on-close-modal');
        },
      }}
    >
      <p>My awesome app</p>
    </VideoAskProvider>
  );
};

Hook usage

import { useVideoAsk } from 'react-videoask-hook';

const MyComponent = () => {
  const { showWidget, hideWidget } = useVideoAsk();

  return (
    <>
      <button onClick={showWidget}>Show video ask</button>
    </>
  );
};

API

Todo |

About

Easily manage Video Ask with a react hook

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published