Files
upscayl/renderer/pages/index.tsx
Nayam Amarshe 0e1e2d1229 Init
2022-08-02 14:28:24 +05:30

35 lines
819 B
TypeScript

import { useEffect } from 'react'
import Link from 'next/link'
import Layout from '../components/Layout'
const IndexPage = () => {
useEffect(() => {
const handleMessage = (_event, args) => alert(args)
// add a listener to 'message' channel
global.ipcRenderer.addListener('message', handleMessage)
return () => {
global.ipcRenderer.removeListener('message', handleMessage)
}
}, [])
const onSayHiClick = () => {
global.ipcRenderer.send('message', 'hi from next')
}
return (
<Layout title="Home | Next.js + TypeScript + Electron Example">
<h1>Hello Next.js 👋</h1>
<button onClick={onSayHiClick}>Say hi to electron</button>
<p>
<Link href="/about">
<a>About</a>
</Link>
</p>
</Layout>
)
}
export default IndexPage