0.0.14 • Published 2 years ago

@getlit/hooks v0.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Getting started

yarn add @getlit/hooks

usePKPs (UMD) example

react usage

import { usePKPs } from "@getlit/hooks";

export default function Home() {
  const [data, loading, errors, fetch, defaultRender] = usePKPs({
    litNetwork: "serrano",
    chain: "ethereum",
  });

  return (
    <>
      <button onClick={fetch}>View PKPs</button>

      {/* -- default render -- */}
      <h2>Default rendering</h2>
      {defaultRender((pkp: any) => {
        console.log(pkp);
      })}

      {/* -- custom render */}
      <h2>Custom rendering</h2>
      {loading ? "Loading PKPs..." : ""}
      {errors ? "Error: " + errors : ""}
      {data?.map((pkp: any) => {
        return (
          <div key={pkp.tokenId}>
            tokenId: {pkp.tokenId} <br />
          </div>
        );
      })}
    </>
  );
}

html usage

<body>
  <div id="root"></div>

  <button id="btn-view-pkps">View PKPs</button>

  <!-- script -->
  <script crossorigin src="https://unpkg.com/react/umd/react.production.min.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom/umd/react-dom.production.min.js"></script>
  <script src="https://www.unpkg.com/@getlit/hooks@0.0.12/dist/bundle.umd.js"></script>
  <script>
    const { usePKPs } = GetLitHooks;

    function YourComponent() {
      const [data, loading, error, fetchPKPs, render] = usePKPs({ litNetwork: "serrano", chain: "ethereum" });

      document.getElementById('btn-view-pkps').onclick = async () => {
        fetchPKPs();
      };
      return React.createElement('div', null, render((pkp) => {
        console.log(pkp);
      }));
    }

    ReactDOM.render(
      React.createElement(YourComponent, null),
      document.getElementById('root')
    );
  </script>
</body>
0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago