Skip to content

Instantly share code, notes, and snippets.

@fmacedoo
Created July 31, 2020 21:13
Show Gist options
  • Save fmacedoo/0236e631b42fafa11859f7c735d9d62f to your computer and use it in GitHub Desktop.
Save fmacedoo/0236e631b42fafa11859f7c735d9d62f to your computer and use it in GitHub Desktop.
import React, { useState } from 'react';
import sendAsync from './message-control/renderer';
import './App.css';
function App() {
const [message, setMessage] = useState('');
const [responses, setResponses] = useState([]);
function send(data) {
sendAsync(data).then((result) => setResponses([...responses, result]));
}
return (
<div className="App">
<header className="App-header">
<h1>
Standalone application with Electron, React, and
SQLite stack.
</h1>
</header>
<article>
<p>
Say <i>ping</i> to the main process.
</p>
<input
type="text"
value={message}
onChange={({ target: { value } }) => setMessage(value)}
/>
<button type="button" onClick={() => send(message)}>
Send
</button>
<br />
<p>Main process responses:</p>
<br />
<pre>
{(responses && responses.join('\n')) ||
'the main process seems quiet!'}
</pre>
</article>
</div>
);
}
export default App;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment