Skip to content

Instantly share code, notes, and snippets.

@abraithwaite
Last active March 24, 2021 15:31
Show Gist options
  • Save abraithwaite/e16e5c599c31b1112a7b0b833ffda420 to your computer and use it in GitHub Desktop.
Save abraithwaite/e16e5c599c31b1112a7b0b833ffda420 to your computer and use it in GitHub Desktop.
Simple PlaidLink Example
import * as React from 'react';
import { Button } from 'antd';
import { PlaidLink, usePlaidLink } from 'react-plaid-link';
export const LinkBankButton = () => {
const [token, setToken] = React.useState<string>("");
React.useEffect(() => {
async function loadToken() {
let x = await (await fetch("/create_link_token", {method: "post"})).json()
console.log(x)
if (x.token !== "") {
setToken(x.token)
}
}
if (token === "") {
loadToken()
}
})
const onSuccess = React.useCallback((pubToken, metadata) => {
// Send this token to your server
console.log(pubToken)
}, []);
const config = {
token: token,
env: 'development',
onSuccess,
};
const { open, ready, error } = usePlaidLink(config);
return (
<Button type="primary" onClick={() => open()} disabled={token === ""} className="login-form-button" > Link Bank </Button>
);
}
@RonquilloAeon
Copy link

Worked perfectly! Thanks.

@abraithwaite
Copy link
Author

Worked perfectly! Thanks.

np!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment