mirror of
https://github.com/oceanprotocol/react.git
synced 2025-02-14 21:10:38 +01:00
more docs updates
This commit is contained in:
parent
977c4e2a83
commit
01ec93658f
14
README.md
14
README.md
@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
- [🏗 Installation](#-installation)
|
- [🏗 Installation](#-installation)
|
||||||
- [🏄 Usage](#-usage)
|
- [🏄 Usage](#-usage)
|
||||||
- [Providers](#providers)
|
- [1. Providers](#1-providers)
|
||||||
- [Hooks](#hooks)
|
- [2. Hooks](#2-hooks)
|
||||||
- [🦑 Development](#-development)
|
- [🦑 Development](#-development)
|
||||||
- [✨ Code Style](#-code-style)
|
- [✨ Code Style](#-code-style)
|
||||||
- [👩🔬 Testing](#-testing)
|
- [👩🔬 Testing](#-testing)
|
||||||
@ -44,9 +44,9 @@ npm install @oceanprotocol/react
|
|||||||
|
|
||||||
## 🏄 Usage
|
## 🏄 Usage
|
||||||
|
|
||||||
First, wrap your whole app with the `Web3Provider` and the `OceanProvider`.
|
First, wrap your whole app with the [`Web3Provider`](src/providers/Web3Provider) and the [`OceanProvider`](src/providers/OceanProvider).
|
||||||
|
|
||||||
### Providers
|
### 1. Providers
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import React, { ReactNode } from 'react'
|
import React, { ReactNode } from 'react'
|
||||||
@ -78,9 +78,9 @@ export default function MyApp({
|
|||||||
|
|
||||||
The `OceanProvider` requires a Web3 instance to be passed as prop so you can replace the basic [`Web3Provider`](src/providers/Web3Provider) with whatever component/library/provider returning a Web3 instance.
|
The `OceanProvider` requires a Web3 instance to be passed as prop so you can replace the basic [`Web3Provider`](src/providers/Web3Provider) with whatever component/library/provider returning a Web3 instance.
|
||||||
|
|
||||||
### Hooks
|
### 2. Hooks
|
||||||
|
|
||||||
Then within your component use the provided hooks to interact with Ocean's functionality. Each hook can be used independently:
|
Then within your component use the included hooks to interact with Ocean's functionality. Each hook can be used independently:
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
@ -156,7 +156,7 @@ npm run format
|
|||||||
The build script will compile `src/` with `tsc` into:
|
The build script will compile `src/` with `tsc` into:
|
||||||
|
|
||||||
1. CommonJS module with ES5 syntax
|
1. CommonJS module with ES5 syntax
|
||||||
2. ES module with ES5 syntax
|
2. ES module with ES6 syntax
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run build
|
npm run build
|
||||||
|
@ -1 +0,0 @@
|
|||||||
// noop
|
|
@ -2,4 +2,4 @@ import './@types/globals'
|
|||||||
|
|
||||||
export * from './providers'
|
export * from './providers'
|
||||||
export * from './hooks'
|
export * from './hooks'
|
||||||
export * from './components'
|
// export * from './components'
|
||||||
|
@ -3,11 +3,11 @@ import Web3 from 'web3'
|
|||||||
async function getWeb3(): Promise<Web3> {
|
async function getWeb3(): Promise<Web3> {
|
||||||
let web3: Web3
|
let web3: Web3
|
||||||
|
|
||||||
// modern dapp browsers
|
// modern dapp browser
|
||||||
if (window.ethereum) {
|
if (window.ethereum) {
|
||||||
web3 = new Web3(window.ethereum as any)
|
web3 = new Web3(window.ethereum)
|
||||||
}
|
}
|
||||||
// legacy dapp browsers
|
// legacy dapp browser
|
||||||
else if (window.web3) {
|
else if (window.web3) {
|
||||||
web3 = new Web3(window.web3.currentProvider)
|
web3 = new Web3(window.web3.currentProvider)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user