try some other things to get working build

This commit is contained in:
Chris Grimmett 2023-12-08 22:34:56 -08:00
parent 5b69871758
commit 510512a58b
2 changed files with 29 additions and 28 deletions

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
lts/iron

View File

@ -1,39 +1,39 @@
'use client';
import { type Helia, createHelia } from 'helia';
import React, { useState, useEffect } from 'react';
// import { type Helia, createHelia } from 'helia';
// import React, { useState, useEffect } from 'react';
export default function Ipfs () {
const [id, setId] = useState<string|null>(null)
const [helia, setHelia] = useState<Helia|null>(null)
const [isOnline, setIsOnline] = useState(false)
// export default function Ipfs () {
// const [id, setId] = useState<string|null>(null)
// const [helia, setHelia] = useState<Helia|null>(null)
// const [isOnline, setIsOnline] = useState(false)
useEffect(() => {
const init = async () => {
if (helia) return
// useEffect(() => {
// const init = async () => {
// if (helia) return
const heliaNode = await createHelia();
// const heliaNode = await createHelia();
const nodeId = heliaNode.libp2p.peerId.toString();
const nodeIsOnline = heliaNode.libp2p.isStarted();
// const nodeId = heliaNode.libp2p.peerId.toString();
// const nodeIsOnline = heliaNode.libp2p.isStarted();
setHelia(heliaNode);
setId(nodeId);
setIsOnline(nodeIsOnline);
}
// setHelia(heliaNode);
// setId(nodeId);
// setIsOnline(nodeIsOnline);
// }
init()
}, [helia])
// init()
// }, [helia])
if (!helia || !id) {
return <h4>Connecting to IPFS...</h4>
}
// if (!helia || !id) {
// return <h4>Connecting to IPFS...</h4>
// }
return (
<div>
<h4 data-test="id">ID: {id.toString()}</h4>
<h4 data-test="status">Status: {isOnline ? 'Online' : 'Offline'}</h4>
</div>
)
}
// return (
// <div>
// <h4 data-test="id">ID: {id.toString()}</h4>
// <h4 data-test="status">Status: {isOnline ? 'Online' : 'Offline'}</h4>
// </div>
// )
// }