2022-01-07 17:05:39 +11:00
|
|
|
import { Waku } from 'js-waku';
|
|
|
|
|
import * as React from 'react';
|
2022-01-07 16:55:27 +11:00
|
|
|
|
|
|
|
|
function App() {
|
2022-01-07 17:05:39 +11:00
|
|
|
const [waku, setWaku] = React.useState(undefined);
|
|
|
|
|
const [wakuStatus, setWakuStatus] = React.useState('None');
|
|
|
|
|
|
|
|
|
|
// Start Waku
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
// If Waku is already assigned, the job is done
|
|
|
|
|
if (!!waku) return;
|
|
|
|
|
// If Waku status not None, it means we are already starting Waku
|
|
|
|
|
if (wakuStatus !== 'None') return;
|
|
|
|
|
|
|
|
|
|
setWakuStatus('Starting');
|
|
|
|
|
|
|
|
|
|
// Create Waku
|
|
|
|
|
Waku.create({ bootstrap: true }).then((waku) => {
|
|
|
|
|
// Once done, put it in the state
|
|
|
|
|
setWaku(waku);
|
|
|
|
|
// And update the status
|
|
|
|
|
setWakuStatus('Started');
|
|
|
|
|
});
|
|
|
|
|
}, [waku, wakuStatus]);
|
|
|
|
|
|
2022-01-07 16:55:27 +11:00
|
|
|
return (
|
2022-01-07 17:05:39 +11:00
|
|
|
<div className='App'>
|
|
|
|
|
<header className='App-header'>
|
|
|
|
|
<p>Waku node's status: {wakuStatus}</p>
|
2022-01-07 16:55:27 +11:00
|
|
|
</header>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App;
|