npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dapperlabs/react-web3

v0.2.0

Published

Context provider for interacting with injected web3.

Downloads

19

Readme

react-web3?

Context provider for interacting with injected web3.

values provided on context:

  • web3: the injected web3 instance
  • checkingForWeb3: boolean indicating whether still actively waiting for injection.
  • account: current user wallet address
  • network: current network id
  • requestAccounts: utility method for requesting the users accounts
  • getAccounts: utility method for accessing the user accounts
  • personalSign: utility method for performing a personal sign

Setup

Import the provider and wrap your application in it.

import { Web3Provider } from '@dapperlabs/react-web3'

function Root() {
  return (
    <Web3Provider>
      <MyDApp />
    </Web3Provider>
  )
}

Context

Context is directly available via import { Web3Context } from '@dapperlabs/react-web3 and can be consumed however you'd like:

  • useContext(Web3Context)
  • static contextType = Web3Context
  • <Web3Context.Consumer />

HOC (withWeb3)

Decorates your component with the above context values spread onto it.


<Web3Toolbar />

Utility component to drop into your app that will render the current values of the context properties.

import { Web3Toolbar } ...

function MyDapp() {
  return (
    <div>
      {process.env.NODE_ENV !== 'production' && (  
        <Web3Toolbar />
      )}
      <OtherStuff />
    </div>
  )
}

Hooks

  • useInjectedWeb3()
  • useWeb3Status( true/false ) where the parameter indicates whether to poll for the status.
function () {
  const [web3, checkingForWeb3] = useInjectedWeb3();
  const [account, network] = useWeb3Status();
  ...
}