Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Latest commit

 

History

History
46 lines (37 loc) · 979 Bytes

README.md

File metadata and controls

46 lines (37 loc) · 979 Bytes

react-method-link

NPM

Install

npm install --save react-method-link

Usage

import React from 'react';
import { useMethodLink } from 'react-method-link';

const App = () => {
  const myAPIClient = {
    exchangeLinkToken: (data) => {},
    generateLinkToken: (options) => {},
  };

  const { openWithToken } = useMethodLink({
    env: 'dev', // Defaults to 'dev'. Use 'production' when you're ready to go live.
    onOpen: () => {},
    onExit: () => {},
    onError: (error) => {},
    onSuccess: data => myAPIClient.exchangeLinkToken(data),
  });
  
  const onClick = async () => {
    const token = await myAPIClient.generateLinkToken({});
    openWithToken(token);
  };

  return (
    <div>
      <header>
        <button type="button" onClick={onClick}>
          Open Method Link
        </button>
      </header>
    </div>
  );
};