1.3.0 • Published 1 month ago

@linagee/lnr-ethers-react v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Lnr Ethers React

npm npm bundle size npm

GitHub GitHub pull requests

code style: prettier

Requirements

  • React >= 18.0.0

Installation

Full documentation can be found here docs.linagee.app

# with npm
npm install @linagee/lnr-ethers-react

# with yarn
yarn add @linagee/lnr-ethers-react

Setup

Set LnrConfigProvider as a wrapper for your app

Example:

import { AppProps } from 'next/app';
import { ethers } from 'ethers';
import { LnrConfigProvider } from '@linagee/lnr-ethers-react';

function MyApp({ Component, pageProps }: AppProps) {
    const config = {
        provider: new ethers.providers.AlchemyProvider(1, process.env.REACT_APP_ALCHEMY_API
        ),
    };

    return (
        <LnrConfigProvider config={config}>
            <Component {...pageProps} />
        </LnrConfigProvider>
    );
}

export default MyApp;

You need to set REACT_APP_ALCHEMY_API in your .env file. You can set any provider you want, but we recommend using Alchemy.


Usage

Use the hooks in your components to get the data you need.

Example:

import React from "react";
import { useLnrGetAddress } from "@linagee/lnr-ethers-react";

function MyComponent() {
  const name = "0xhal.og";
  const { address, error, hasError, loading } = useLnrGetAddress(name);

  if (loading) {
    return <div>Loading...</div>;
  }

  if (hasError) {
    return <div>Error: {error}</div>;
  }

  return (
    <div>
      <h2>Name: {name}</h2>
      <p>Address: {address}</p>
    </div>
  );
}

export default MyComponent;
1.3.0

1 month ago

1.2.0

1 year ago

1.2.0-rc.2

1 year ago

1.2.0-rc.1

1 year ago

1.2.0-rc.0

1 year ago

1.2.0-rc.5

1 year ago

1.2.0-rc.4

1 year ago

1.2.0-rc.3

1 year ago

1.1.1

1 year ago

1.1.1-rc.1

1 year ago

1.1.1-rc.0

1 year ago

1.1.0

1 year ago

1.0.30

1 year ago