@codat/sdk-link-types
v1.11.0
Published
This package contains the type definitions and initialize helper methods to use with the dynamically imported Codat SDKs: Embedded Link, Connections, and Bank Feeds.
Downloads
14,182
Readme
This package contains the type definitions and initialize helper methods to use with the dynamically imported Codat SDKs: Embedded Link, Connections, and Bank Feeds.
Installation
You can install this library using npm:
$ npm i -S @codat/sdk-link-typesUsage
Embedded Link
To render the CodatLink component in React:
import React, { useEffect, useState } from "react";
import ReactDOM from "react-dom/client";
import { CodatLinkProps, initializeCodatLink } from "@codat/sdk-link-types";
const CodatLink: React.FC<CodatLinkProps> = (props: CodatLinkProps) => {
const [componentMount, setComponentMount] = useState<HTMLDivElement | null>(
null
);
useEffect(() => {
const target = componentMount;
if (target && target.children.length === 0) {
initializeCodatLink(target, props);
}
// CodatLink does not support changing props after initialisation.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [componentMount]);
return (
<div
style={{
// Recommended dimensions
width: "460px",
height: "840px",
maxHeight: "95%",
}}
ref={setComponentMount}
></div>
);
};
const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement
);
root.render(
<React.StrictMode>
<CodatLink
companyId="COMPANY_ID"
onClose={() => alert("onClose")}
onError={() => alert("onError")}
onConnection={() => alert("onConnection")}
onConnectionStarted={() => alert("onConnectionStarted")}
onFinish={() => alert("onFinish")}
options={{}}
/>
</React.StrictMode>
);Connections
To render the CodatConnections component in React:
import React, { useEffect, useState } from "react";
import ReactDOM from "react-dom/client";
import {
CodatConnectionsProps,
initCodatConnections,
} from "@codat/sdk-link-types/connections";
const CodatConnections: React.FC<CodatConnectionsProps> = (
props: CodatConnectionsProps
) => {
const [componentMount, setComponentMount] = useState<HTMLDivElement | null>(
null
);
useEffect(() => {
const target = componentMount;
if (target && target.children.length === 0) {
initCodatConnections(target, props);
}
// CodatConnections does not support changing props after initialization.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [componentMount]);
return (
<div
style={{
// Recommended dimensions
width: "460px",
height: "840px",
maxHeight: "95%",
}}
ref={setComponentMount}
></div>
);
};
const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement
);
root.render(
<React.StrictMode>
<CodatConnections
accessToken="ACCESS_TOKEN"
onClose={() => alert("onClose")}
onError={() => alert("onError")}
onDisconnect={() => alert("onDisconnect")}
onReconnect={() => alert("onReconnect")}
options={{}}
/>
</React.StrictMode>
);Bank Feeds
To render the CodatBankFeeds component in React:
import React, { useEffect, useState } from "react";
import ReactDOM from "react-dom/client";
import {
CodatBankFeedsProps,
initCodatBankFeeds,
} from "@codat/sdk-link-types/bank-feeds";
const CodatBankFeeds: React.FC<CodatBankFeedsProps> = (
props: CodatBankFeedsProps
) => {
const [componentMount, setComponentMount] = useState<HTMLDivElement | null>(
null
);
useEffect(() => {
const target = componentMount;
if (target && target.children.length === 0) {
initCodatBankFeeds(target, props);
}
// CodatBankFeeds does not support changing props after initialisation.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [componentMount]);
return (
<div
style={{
// Recommended dimensions
width: "460px",
height: "840px",
maxHeight: "95%",
}}
ref={setComponentMount}
></div>
);
};
const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement
);
root.render(
<React.StrictMode>
<CodatBankFeeds
accessToken="ACCESS_TOKEN"
companyId="COMPANY_ID"
onClose={() => alert("onClose")}
onError={() => alert("onError")}
onConnection={() => alert("onConnection")}
onConnectionStarted={() => alert("onConnectionStarted")}
onFinish={() => alert("onFinish")}
options={{}}
/>
</React.StrictMode>
);See our examples of setting up with other languages.
Docs
For more information, see our docs
