1
0
mirror of https://github.com/oceanprotocol/react.git synced 2024-11-22 09:47:06 +01:00
🎣 React hooks & components on top of squid.js
Go to file
2020-04-24 16:38:24 +02:00
README.md initial concept 2020-04-24 16:38:24 +02:00

@oceanprotocol/react

React hooks & components on top of squid.js

Installation

npm install @oceanprotocol/react

Usage

import React from 'react'
import { useOcean, OceanConfig, useConsume } from '@oceanprotocol/react'

const oceanConfig: OceanConfig = {
    nodeUri: '',
    ...
}

export default function MyComponent() {
  // TODO: setup web3 first
  const { ocean, account } = useOcean(web3, oceanConfig)
  const { consumeAsset, isLoading, step } = useConsume()

  async function handleClick() {
      const ddo = 'did:op:0x000000000'
      await consumeAsset(ddo)
  }

  return (
    <div>
        Your account: {account}

        <button onClick={handleClick}>
            {isLoading ? step : 'Download Asset' }
        </button>
    </div>
  )
}