@tryfinch/react-connect
Install
npm install --save @tryfinch/react-connect
Usage
import React, { useState } from 'react';
import { useFinchConnect } from '@tryfinch/react-connect';
const App = () => {
const [code, setCode] = useState(null);
const onSuccess = ({ code }) => setCode(code);
const onError = ({ errorMessage, errorType }) => console.error(errorMessage, errorType);
const onClose = () => console.log('User exited Finch Connect');
const { open } = useFinchConnect({
clientId: '<your-client-id>',
products: ['company', 'directory'],
onSuccess,
onError,
onClose,
});
return (
<div>
<header>
<p>Code: {code}</p>
<button type="button" onClick={() => open()}>
Open Finch Connect
</button>
</header>
</div>
);
};