react-ipfs-provider
v1.0.6
Published
react-ipfs-provider React component
Downloads
14
Readme
react-ipfs-provider
IPFS Context Provider for React, all the fun of IPFS with as little prop drilling and double locking repo's as possible
Install
With NPM
npm i --save react-ipfs-provider
With Yarn
yarn add react-ipfs-provider
Usage
App.js
import React from 'react';
import Component from './component';
import { Provider } from 'react-ipfs-provider';
export default function App(props){
return (
<Provider ipfs={/* optional ipfs node prop */}>
<div>
<Component />
</div>
</Provider>
);
}
Component.js
import React from 'react';
import { withIPFS } from 'react-ipfs-provider';
function Component(props){
React.useEffect(() => {
props.ipfs.add('Content to IPFS')
}, [])
return (
<div>
{props.ipfs.provider.id}
</div>
);
}
export default withIPFS(Component)