mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
initial concept
This commit is contained in:
commit
c7558bd769
42
README.md
Normal file
42
README.md
Normal file
@ -0,0 +1,42 @@
|
||||
# @oceanprotocol/react
|
||||
|
||||
> React hooks & components on top of squid.js
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install @oceanprotocol/react
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```tsx
|
||||
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>
|
||||
)
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user