1.0.5 • Published 3 years ago
react-method-link v1.0.5
react-method-link
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: 'sandbox', // Defaults to 'sandbox'. 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>
);
};