A redux bundle to create an IPFS instance and pass it as an
extraArg
to other store methods.
See https://reduxbundler.com for more info on the wonders of redux bundles.
Uses window.ipfs-fallback
to find the best IPFS instance available. This will window.ipfs
if you have IPFS Companion installed, or a js-ipfs-api
instance otherwise.
Add ipfs-redux-bundle
to your store
bundles/index.js
import { composeBundles } from 'redux-bundler'
import ipfsBundle from 'ipfs-redux-bundle'
// ... import other bundles
export default composeBundles(
ipfsBundle()
// ... add bundles here
)
In your app, you can now connect
up the doInitIpfs
function. Here we init IPFS when our root component mounts:
App.js
import React, { Component } from 'react'
import { connect } from 'redux-bundler-react'
export class App extends Component {
componentDidMount () {
this.props.doInitIpfs()
}
render () {
// ipfs-css powered gorgeous ui here.
}
}
export default connect(
'doInitIpfs',
App
)
Adds the following methods to the redux store
boolean
- Is the IPFS instance ready to use yet?
boolean
- Did the IPFS instance fail to start?
Object
- The last resolved value ofipfs.id()
string
- The API address of the IPFS instance.
- Create a new IPFS instance. This will
window.ipfs
if you have IPFS Companion installed, or ajs-ipfs-api
instance otherwise.
- Updates the API Address to
address
.
Feel free to dive in! Open an issue or submit PRs.
MIT © Protocol Labs