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
README.md |
@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>
)
}