Skip to content

The-Poolz/PoolzReactHelper

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

18405c6 · May 19, 2024
Mar 7, 2024
Jun 6, 2023
May 19, 2024
Apr 12, 2024
Jun 6, 2023
Jul 10, 2023
Feb 8, 2023
May 9, 2024
Apr 18, 2024
Jul 10, 2023
Mar 3, 2023

Repository files navigation

ReactHelper

Reporting Bugs / Feature Requests

Open Bugs Feature Requests Closed Issues

Coverage Bugs Security Rating Code Smells Quality Gate Status Duplicated Lines (%)

Installation

You can install the package either using NPM or using Yarn

Using NPM

npm install @poolzfinance/reacthelper

Yarn

yarn add @poolzfinance/reacthelper

Usage

src/index.tsx

import { StrictMode } from "react"
import { createRoot } from "react-dom/client"
import { ThePoolzProvider } from "@poolzfinance/reacthelper"
import App from "./App"

const rootElement = document.getElementById("root")
const root = createRoot(rootElement!)

root.render(
  <StrictMode>
    <ThePoolzProvider>
      <App />
    </ThePoolzProvider>
  </StrictMode>
)

Connect MetaMask wallet

src/App.tsx

import { useThePoolz, useConnectWallet } from "@poolzfinance/reacthelper"

export default function App() {
  const thePoolz = useThePoolz()
  const { account } = thePoolz
  const { isMetamask, connectMetamask } = useConnectWallet()

  return (
    <div>
      <h1>ReactHelper</h1>
      {account || (
        <button
          onClick={async () => {
            try {
              await connectMetamask()
            } catch (error) {
              console.error(error)
            }
          }}>
          {!isMetamask && "Install"} Metamask
        </button>
      )}
    </div>
  )
}

Demo: SandBox