Skip to content

Commit 1f8684d

Browse files
author
Alan Shaw
authored
docs: update examples (ipfs#2319)
Since I was going through these anyway to ensure they work with [0.37](ipfs#2192) I've updated the examples to use the new [`IPFS.create` constructor](https://github.com/ipfs/js-ipfs#ipfs-constructor) and switched to using the promised API so that we onboard new users to using promises and minimise the disruption caused when ipfs#1670 bubbles up to here. License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent 2d7370c commit 1f8684d

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"dependencies": {
66
"dot-prop": "^5.0.0",
77
"ipfs": "file:../../",
8-
"ipfs-css": "^0.12.0",
8+
"ipfs-css": "^0.13.1",
99
"react": "^16.8.0",
1010
"react-dom": "^16.8.0",
1111
"react-scripts": "3.0.1",

src/hooks/use-ipfs-factory.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default function useIpfsFactory ({ commands }) {
4040
} else {
4141
try {
4242
console.time('IPFS Started')
43-
ipfs = await promiseMeJsIpfs(Ipfs, {})
43+
ipfs = await Ipfs.create()
4444
console.timeEnd('IPFS Started')
4545
} catch (error) {
4646
console.error('IPFS init error:', error)
@@ -54,11 +54,3 @@ export default function useIpfsFactory ({ commands }) {
5454

5555
return { ipfs, isIpfsReady, ipfsInitError }
5656
}
57-
58-
function promiseMeJsIpfs (Ipfs, opts) {
59-
return new Promise((resolve, reject) => {
60-
const ipfs = new Ipfs(opts)
61-
ipfs.once('ready', () => resolve(ipfs))
62-
ipfs.once('error', err => reject(err))
63-
})
64-
}

0 commit comments

Comments
 (0)