1.2.1 • Published 23 days ago

@codat/sdk-link-types v1.2.1

Weekly downloads
-
License
-
Repository
-
Last release
23 days ago

This package contains the type definitions and initialize helper method to use with the dynamically imported Embedded Link.

Installation

You can install this library using npm:

$ npm i -S @codat/sdk-link-types

Usage

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>
  );
};

// The code below is an example of how to render the component at the root level of the application

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")}
      onFinish={() => alert("onFinish")}
      options={{}}
    />
  </React.StrictMode>
);

See our examples of setting up with other languages.

Docs

For more information, see our docs

1.2.1

23 days ago

1.2.0

2 months ago

1.2.0-alpha.1

4 months ago

1.1.0-beta.1

6 months ago

1.1.0-alpha.3

7 months ago

1.1.0-alpha.2

7 months ago

1.1.0-alpha.1

7 months ago

1.0.0

7 months ago

0.0.1-alpha.1

7 months ago