Reusable React.js components and hooks
This repo contains two reusable pieces that are common amongst all Polymath standalone apps:
const {error, sdk, networkId, walletAddress} = usePolymathSdk(): call this hook inside your functional components. It will attempt to:- instantiate an SDK instance.
- Connect to Polymath network
- Get the current browser wallet address (eg from Metamask)
- return an error, if any.
const {error, tokenSelector, tokens, tokenIndex} = useTokenSelector(sdk, walletAddress): call this hook to fetch all the seurity tokens that are either owned bywalletAddressor are delegated to be managed bywalletAddress. The hook returns:tokensan array of security token objects.tokenSelectora React select list that enables selecting a token to manage.tokenIndexis the index of currently selected token if any.
yarn add PolymathNetwork/react. Yes, we will release this repo as an npm pacakge soon!
To see those hooks actions please checkout our role management app.